Skip to content

Nginx problems

Learn how to fix Nginx problems

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

More Information

Reference

This error typically occurs in alpine docker image. Since the nginx image already have a user called nginx. We will reuse it.

Dockerfile
FROM nginx:alpine

RUN touch /var/run/nginx.pid \
   && chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid

COPY --chown=nginx:nginx <your-files> /usr/share/nginx/html
COPY --chown=nginx:nginx <your-nginx-config> /etc/nginx/conf.d/default.conf

USER nginx
...