diff --git a/Dockerfile-alpine-slim.template b/Dockerfile-alpine-slim.template index 2ba937c5..0a550e9d 100644 --- a/Dockerfile-alpine-slim.template +++ b/Dockerfile-alpine-slim.template @@ -95,7 +95,7 @@ RUN set -x \ # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ - && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index bc864472..92788e8d 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -128,7 +128,7 @@ RUN set -x \ # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ - && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \ diff --git a/README.md b/README.md index f2684d76..d8c53bac 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This repo contains a series of Dockerfiles to create an NGINX Docker image that - The default NGINX listen port is now `8080` instead of `80` (this is no longer necessary as of Docker `20.03` but it's still required in other container runtimes) - The default NGINX user directive in `/etc/nginx/nginx.conf` has been removed -- The default NGINX PID has been moved from `/var/run/nginx.pid` to `/tmp/nginx.pid` +- The default NGINX PID has been moved from `/var/run/nginx.pid` (prior to NGINX 1.27.5) and `/run/nginx.pid` (NGINX 1.27.5 and later) to `/tmp/nginx.pid` - Change `*_temp_path` variables to `/tmp/*` Check out the [docs](https://hub.docker.com/_/nginx) for the upstream Docker NGINX image for a detailed explanation on how to use this image. @@ -51,7 +51,7 @@ Most images are built for the `amd64`, `arm32v5` (for Debian), `arm32v6` (for Al ``` - If you override the default `nginx.conf` file you may encounter various types of error messages: - - To fix `nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)`, you have to specify a valid `pid` location by adding the line `pid /tmp/nginx.pid;` at the top level of your config. + - To fix `nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)`, you have to specify a valid `pid` location by adding the line `pid /tmp/nginx.pid;` at the top level of your config. NOTE: NGINX 1.27.5 will complain about permissions for `/run/nginx.pid` due to a policy change for this path. - To fix `nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (30: Read-only file system)`, you have to specify a valid location for the various NGINX temporary paths by adding these lines within the `http` context: ```nginx diff --git a/mainline/alpine-slim/Dockerfile b/mainline/alpine-slim/Dockerfile index 5506f098..1bdbfbc0 100644 --- a/mainline/alpine-slim/Dockerfile +++ b/mainline/alpine-slim/Dockerfile @@ -101,7 +101,7 @@ RUN set -x \ # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ - && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \ diff --git a/mainline/debian/Dockerfile b/mainline/debian/Dockerfile index d78d860d..2cca5eaa 100644 --- a/mainline/debian/Dockerfile +++ b/mainline/debian/Dockerfile @@ -138,7 +138,7 @@ RUN set -x \ # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ - && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \ diff --git a/stable/alpine-slim/Dockerfile b/stable/alpine-slim/Dockerfile index cda3a72d..6c591082 100644 --- a/stable/alpine-slim/Dockerfile +++ b/stable/alpine-slim/Dockerfile @@ -101,7 +101,7 @@ RUN set -x \ # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ - && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \ diff --git a/stable/debian/Dockerfile b/stable/debian/Dockerfile index f0c675d1..7217d8b6 100644 --- a/stable/debian/Dockerfile +++ b/stable/debian/Dockerfile @@ -138,7 +138,7 @@ RUN set -x \ # implement changes required to run NGINX as an unprivileged user RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \ && sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ - && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ # nginx user must own the cache and etc directory to write cache and tweak the nginx config && chown -R $UID:0 /var/cache/nginx \