I am trying to run nginx in a docker container, setting the configuration and static html files to serve it. Very simple, as far as I know, but I always get an error when the directory is not a directory?
I run this example on my Mac using the latest version of Boot2Docker.
I have the following folder structure:
% tree ~/Projects/Docker/nginx-example . ├── html │ └── test.html └── nginx.conf 1 directory, 2 files
The contents of nginx.conf are as follows:
http { server { listen *:80; # Listen for incoming connections from any interface on port 80 server_name ""; # Don't worry if "Host" HTTP Header is empty or not set root /usr/share/nginx/html; # serve static files from here } }
I am trying to start a container (from ~/Projects/Docker/nginx-example directory) as follows:
docker run --name nginx-container \ -v /Users/M/Projects/Docker/nginx-example/html:/usr/share/nginx/html:ro \ -v /Users/M/Projects/Docker/nginx-example/nginx.conf:/etc/nginx:ro \ -P -d nginx
I initially tried something like -v $(pwd)/html:/usr/share/nginx/html:ro to make the command shorter, but when that didn’t work, I thought I would be explicit if there were any something funky shell issue I didn't know about
And I get the following output
fc41205914098d236893a3b4e20fa89703567c666ec1ff29f123215dfbef7163 Error response from daemon: Cannot start container fc41205914098d236893a3b4e20fa89703567c666ec1ff29f123215dfbef7163: [8] System error: not a directory
Does anyone know what I am missing?
Issue with Mac Boot2Docker?
I know that there is a problem with mounting volumes into containers when using Boot2Docker (although I am convinced that this has long been resolved)
i.e. Install Volume on Docker Image on OSX
But I followed the instructions there, despite this, and it still didn't work.