docker-nginx: mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)

Hello, I’m using the image nginx:alpine and sometime for the first docker-compose up -d I got this error spammed in logs and container restarting:

mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)

If I docker-compose up -d again my container will be fixed but why ?

Best regards, Lucas BOPP

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 4
  • Comments: 19 (1 by maintainers)

Most upvoted comments

go to https://hub.docker.com/_/nginx and find section “Running nginx as a non-root user” you need to change some paths in your config

FYI, i had the same if i run nginx with my host user id ie

nginx:
    user: $UID

Can you show me the output of the following command cd /var/cache/nginx ls

my problem was solved by creating “client_temp” directory in /var/cache/nginx.

P.S: I am not using docker.

I have the same problem on Azure AKS. In this case I don’t know what to change.

P.S. There is also permission problem with nginx.pid, but I change path to /tmp/nginx.pid