Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

nginx

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.

like image 987
425nesp Avatar asked Jan 21 '26 16:01

425nesp


1 Answers

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
like image 193
VonC Avatar answered Jan 23 '26 07:01

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!