Skip to content

Commit 862160b

Browse files
authored
fix: NGINX PID default path has changed in NGINX 1.27.5 and 1.28.0 (#303)
1 parent 8655fa1 commit 862160b

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

Dockerfile-alpine-slim.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ RUN set -x \
9595
# implement changes required to run NGINX as an unprivileged user
9696
RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
9797
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
98-
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
98+
&& sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
9999
&& 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 \
100100
# nginx user must own the cache and etc directory to write cache and tweak the nginx config
101101
&& chown -R $UID:0 /var/cache/nginx \

Dockerfile-debian.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ RUN set -x \
128128
# implement changes required to run NGINX as an unprivileged user
129129
RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
130130
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
131-
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
131+
&& sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
132132
&& 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 \
133133
# nginx user must own the cache and etc directory to write cache and tweak the nginx config
134134
&& chown -R $UID:0 /var/cache/nginx \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This repo contains a series of Dockerfiles to create an NGINX Docker image that
1111

1212
- 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)
1313
- The default NGINX user directive in `/etc/nginx/nginx.conf` has been removed
14-
- The default NGINX PID has been moved from `/var/run/nginx.pid` to `/tmp/nginx.pid`
14+
- 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`
1515
- Change `*_temp_path` variables to `/tmp/*`
1616

1717
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
5151
```
5252

5353
- If you override the default `nginx.conf` file you may encounter various types of error messages:
54-
- 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.
54+
- 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.
5555
- 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:
5656

5757
```nginx

mainline/alpine-slim/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ RUN set -x \
101101
# implement changes required to run NGINX as an unprivileged user
102102
RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
103103
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
104-
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
104+
&& sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
105105
&& 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 \
106106
# nginx user must own the cache and etc directory to write cache and tweak the nginx config
107107
&& chown -R $UID:0 /var/cache/nginx \

mainline/debian/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ RUN set -x \
138138
# implement changes required to run NGINX as an unprivileged user
139139
RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
140140
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
141-
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
141+
&& sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
142142
&& 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 \
143143
# nginx user must own the cache and etc directory to write cache and tweak the nginx config
144144
&& chown -R $UID:0 /var/cache/nginx \

stable/alpine-slim/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ RUN set -x \
101101
# implement changes required to run NGINX as an unprivileged user
102102
RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
103103
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
104-
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
104+
&& sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
105105
&& 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 \
106106
# nginx user must own the cache and etc directory to write cache and tweak the nginx config
107107
&& chown -R $UID:0 /var/cache/nginx \

stable/debian/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ RUN set -x \
138138
# implement changes required to run NGINX as an unprivileged user
139139
RUN sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
140140
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
141-
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
141+
&& sed -i 's,\(/var\)\{0\,1\}/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
142142
&& 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 \
143143
# nginx user must own the cache and etc directory to write cache and tweak the nginx config
144144
&& chown -R $UID:0 /var/cache/nginx \

0 commit comments

Comments
 (0)