425nesp
425nesp

Reputation: 7593

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.

Upvotes: 3

Views: 7352

Answers (1)

VonC
VonC

Reputation: 1326376

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

Upvotes: 4

Related Questions