I'm trying to run nginx within a docker container whilst mounting the configuration and static html files for it to serve up. Very simple stuff as far as I'm aware, but I keep getting an error about the directory not being a directory?
I'm running 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 the nginx.conf
is 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 try to run the container (from within the ~/Projects/Docker/nginx-example
directory) like so:
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
Originally I had tried something like
-v $(pwd)/html:/usr/share/nginx/html:ro
to keep the command shorter, but when it didn't work I thought I'd be explicit just in case there was some funky sub shell issue I wasn't aware of
And I get the following output
fc41205914098d236893a3b4e20fa89703567c666ec1ff29f123215dfbef7163
Error response from daemon:
Cannot start container fc41205914098d236893a3b4e20fa89703567c666ec1ff29f123215dfbef7163:
[8] System error: not a directory
Does anyone have any idea of what I'm missing?
Mac Boot2Docker Volume issue?
I'm aware there is an issue with mounting volumes into containers when using Boot2Docker (although I'm led to believe this has long been resolved)
i.e. Mount volume to Docker image on OSX
But I followed the instructions there regardless, and it still didn't work