Mounting nginx conf as a docker volume causes system error boot2docker


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 <blockquote>

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?

<h2>Mac Boot2Docker Volume issue?</h2>

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. <a href="https://stackoverflow.com/questions/26348353/mount-volume-to-docker-image-on-osx/27540955#27540955" rel="nofollow">Mount volume to Docker image on OSX</a>

But I followed the instructions there regardless, and it still didn't work


-v /Users/M/Projects/Docker/nginx-example/nginx.conf:/etc/nginx:ro

you are attempting to mount a file to a directory - change that to:

-v /Users/M/Projects/Docker/nginx-example/nginx.conf:/etc/nginx/nginx.conf:ro and you should be fine. Take a look at the examples in the <a href="https://docs.docker.com/userguide/dockervolumes/" rel="nofollow">Docker Volumes Docs</a>

As well, pwd should work in the path. The shell expands this before the docker command is run, just like math and inner parenthesis, inner sub-commands are run first.


  • Choosing the right path in a require statement
  • Can't load installed PHP version in Apache (Homebrew OS X)
  • Accessing the main thread in a TKinter script?
  • Can't access my folder because of WordPress [closed]
  • Open view controller when remote notification pressed
  • Configuration class - Get configuration array from the function string argument
  • How to mount volume into the source code of the app?
  • NodeJS using node-serialport sometimes becomes unresponsive
  • Connection between Node.JS and PHP via UNIX Socket - EPIPE write error
  • Warning: ldap_start_tls() [function.ldap-start-tls]: Unable to start TLS: Server is unavailable
  • Node can't scrape certain pages
  • Thread Synchronization with IntentService
  • does the FROM directive in a dockerfile allways pull the latest version of an image
  • Creating new docker-machine instance always fails validating certs using openstack driver
  • Sails.js to client using sails.sockets.join and sails.sockets.broadcast doesn't return info to
  • Simple command-line app I/O in Dart
  • Can't configure nginx as a proxy for tomcat with context path
  • How to update docker-compose on Docker for Windows?
  • What is wrong in my MVC implementation?
  • limited threads in soapUI free version
  • Version in docker-compose is unsupported
  • HikariPool-1 - Unusual system clock change detected, soft-evicting connections from pool
  • how to bypass pinentry (passphrase screen) while decrypting a file using gpgme
  • Can't connect Entity Framework to local SQL Server Express
  • Run script file on remote server
  • Sending Content-Type application/x-www-form-urlencoded WSO2 ESB
  • Unix Network Programming Clarification
  • python script hangs on input method when running spark
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • JSON with duplicate key names losing information when parsed
  • Jquery - Jquery Wysiwyg return html as a string
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy