I want to mount the /etc/nginx folder to a custom folder on my host. However, whenever I try this the container doesn't run at all. Mounting anything else doesnt seem to be problem, though the folder I want it to mount to is always empty.
I tried using /usr/local/nginx/conf or /usr/local/etc/nginx instead of /etc/nginx but the folder is always empty. Though here the container runs at least. Which is what lead me to believe it is this specific mounting that is causing problems.
This is what I want to do.
docker run -p 80:80 -p 443:443 -v /home/pi/nginx_files/config:/etc/nginx -v /home/pi/nginx_files/certs:/etc/ssl/private -d nginx
The container seems to run with any other folder, as ive tried
docker run -p 80:80 -p 443:443 -v /home/pi/nginx_files/config:/etc/nginx/b -v /home/pi/nginx_files/certs:/etc/ssl/private -d nginx
Just to see if any non existent folder doesn't have that problem.
Before that I tried using docker composer and the docker-compose.yaml
version: '3'
services:
reverse:
container_name: reverse
hostname: reverse
image: nginx
ports:
- 80:80
- 443:443
volumes:
- <path/to/your/config>:/etc/nginx
- <path/to/your/certs>:/etc/ssl/private
and
tried docker-compose up
However it suffered from the same problem, where it doesn't even start the container. Error Message:
Creating network "nginx_files_default" with the default driver
Creating reverse ... done
Attaching to reverse
reverse | 2019/08/31 00:41:07 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
reverse | nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
reverse exited with code 1
If I use nonexistent folders it just gets stuck in "Attaching to reverse" indefinitely. But I dont get a message "no such file or directory" although the folders have completely made up names and definitely dont exist.
Did I missunderstand the point of mounting? I thought I'd get to look at the default.conf file by having the container save it on the host, but does it not create one? Do I have to create one myself and then mount it to the container? Does mounting create a folder to read from for the container and not a folder to write to? I'm fairly new to docker and linux so forgive me if this is a rather stupid question.