Hello,
I have some docker container running in a little server.
I have problems with nginx container, I can not mount “/etc/nginx” container folder to my host. This is my configuration:
$ cat docker-compose.yml
version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
volumes:
- $PWD/docker_data/nginx/conf:/etc/nginx
ports:
- 80:80
- 443:443
restart: always
This is the output:
2020/04/05 15:19:58 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory),
nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory),
2020/04/05 15:20:00 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory),
nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory),
And this the host folder permssions:
$ ls -lha docker_data/nginx/
total 12K
drwxr-xr-x 3 root root 4,0K abr 5 17:19 .
drwxr-xr-x 11 root root 4,0K abr 5 17:19 ..
drwxr-xr-x 2 root root 4,0K abr 5 17:19 conf
I try to change the to alpine image (nginx:alpine), but same error.
The only way to get it working is to declare a volume for the configuration:
version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
volumes:
- nginx-config:/etc/nginx
ports:
- 80:80
- 443:443
restart: always
volumes:
nginx-config:
But I want to get the configuration files in my home folder. It works well for other containers I have in the same host.
Am I missing any special configuration?
Kind regards.