简体   繁体   中英

Why does Docker fail to open nginx.conf when I try to mount a volume?

I'm on OS X. First, I used docker pull nginx to get the official image from Docker hub. Next, I created a folder on my host and I'm trying to map (not sure what the correct vernacular is) the nginx configuration directory to my host. So, I tried this.

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

However, that command results in 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 checked inside of the container and I can confirm that file exists.

NGiNX in the container looks for nginx.conf when starting.

That means you need /Users/me/helloworld/nginx/conf/nginx.conf in order for the mounted volume to give the right file at the right place.

How to grab a copy of the configuration files in the container?

You can run it without mounting any host folder:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM