I have the following docker_compose.yaml:
version: "3.8" services: reverse-proxy: image: nginx:1.17.10 container_name: reverse_proxy volumes: - ../nginx/nginx.conf:/etc/nginx/nginx.conf ports: - "8050:8050" - "8051:8051" webapp: image: my-site command: --port 8050 8051 --debug yes volumes: - /home/user/data:/data ports: - "8050:8050" - "8051:8051" depends_on: - reverse-proxy
When I run via docker compose I get the following error:
$ sudo docker-compose -f /home/user/docker_compose.yaml up ... reverse_proxy | 2022/03/09 00:49:19 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (13: Permission denied) reverse_proxy | nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (13: Permission denied) reverse_proxy exited with code 1
So to investigate I re-ran just the nginx container:
$ sudo docker run -v ../nginx/nginx.conf:/etc/nginx/nginx.conf -t docker.io/nginx tail -f /dev/null
ssh
‘d in and I see:
root@d8e84f89fcad:/# ls -la /etc/nginx/ ls: cannot access '/etc/nginx/nginx.conf': Permission denied total 20 drwxr-xr-x. 3 root root 132 Mar 1 14:00 . drwxr-xr-x. 1 root root 66 Mar 9 00:54 .. drwxr-xr-x. 2 root root 26 Mar 1 14:00 conf.d -rw-r--r--. 1 root root 1007 Jan 25 15:03 fastcgi_params -rw-r--r--. 1 root root 5349 Jan 25 15:03 mime.types lrwxrwxrwx. 1 root root 22 Jan 25 15:13 modules -> /usr/lib/nginx/modules -?????????? ? ? ? ? ? nginx.conf -rw-r--r--. 1 root root 636 Jan 25 15:03 scgi_params -rw-r--r--. 1 root root 664 Jan 25 15:03 uwsgi_params
I consulted the following Q and others and they seem to suggest to just restart the docker service, so I did and I still get ?
permissions upon re running.
I assume that this is causing the permission error? If so, how can I set the correct permissions on this nginx config file? Is this really a volume permission issue?
Versions:
Docker version 1.13.1, build 7d71120/1.13.1 docker-compose version 1.29.2, build 5becea4c CentOS 7
Advertisement
Answer
I think it was an SELinux thing, appending :z
to the volume fixed it.
volumes: - ../nginx/nginx.conf:/etc/nginx/nginx.conf:z