Skip to content

Commit 2df3d81

Browse files
author
Bryan Latten
committed
Dockerfile: working around AUFS permission bug
Mostly seen downstream when using nginx as fastcgi proxy
1 parent a5a57b4 commit 2df3d81

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
5555
# Set nginx to listen on defined port \
5656
sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE
5757

58-
RUN goss -g goss.nginx.yaml validate
58+
RUN goss -g goss.nginx.yaml validate && \
59+
/tmp/aufs_hack.sh
5960

6061
# Using a non-privileged port to prevent having to use setcap internally
6162
EXPOSE ${CONTAINER_PORT}

Dockerfile-alpine

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
4141
bash -c "chown www-data:www-data /var/{lib,log}/nginx -Rh" && \
4242
bash -c "chmod 0755 -R /var/{lib,log}/nginx"
4343

44-
RUN goss -g goss.nginx.yaml validate
44+
RUN goss -g goss.nginx.yaml validate && \
45+
/tmp/aufs_hack.sh
4546

4647
# Using a non-privileged port to prevent having to use setcap internally
4748
EXPOSE ${CONTAINER_PORT}

container/root/tmp/aufs_hack.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Use this to wipe the temp files/folders generated when `nginx -t`
4+
# NOTE: must be run after a goss test!
5+
#
6+
# @see https://github.com/docker/docker/issues/20240
7+
#
8+
# In some versions of AUFS, permissions do not set/inherit properly.
9+
# This can cause folders that are created in a different layer than
10+
# they are used to not properly respect permissions.
11+
#
12+
# For example, when testing nginx's configuration, the temp folders
13+
# are generated, but cannot be accessed by nginx while running.
14+
15+
echo "[hack] removing test nginx files and folders"
16+
17+
rm -rfv \
18+
/tmp/.nginx/client_body \
19+
/tmp/.nginx/fastcgi_temp \
20+
/tmp/.nginx/scgi_temp \
21+
/tmp/.nginx/uwsgi_temp \
22+
/tmp/.nginx/proxy_temp \
23+
/tmp/.nginx/nginx.pid

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ubuntu:
99
S6_KILL_GRACETIME: 1
1010
volumes:
1111
- ./container/root/goss.nginx.yaml:/goss.nginx.yaml
12+
- ./container/root/var/www/html:/var/www/html
1213
alpine:
1314
build: .
1415
dockerfile: Dockerfile-alpine

0 commit comments

Comments
 (0)