Why is Docker unable to open nginx.conf when I try to mount a volume?

I'm on OS X. I first used docker pull nginx

to get the official image from the Docker hub. Then I created a folder on my host and I am trying to map (not sure what is the correct language) the nginx config directory for my host. So I tried this.

docker run -p 80:80 --rm -v /Users/me/helloworld/nginx/conf:/etc/nginx/ nginx

      

However, this command leads to this.

2015/05/08 23:42:47 [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)

      

I have checked inside the container and I can confirm that the file exists.

+3


source to share


1 answer


NGiNX looks in the container nginx.conf

at startup.

This means that you need the /Users/me/helloworld/nginx/conf/nginx.conf

mounted volume to provide the right file in the right place.

How do I grab a copy of the config files in a container?



You can run it without setting any host folder:

docker run --rm -it nginx cat /etc/nginx/nginx.conf

      

+2


source







All Articles