Docker Community Forums

Share and learn in the Docker community.

Trying to mount volume with Docker for Windows with workspace


(Sgwatdh) #1

Expected behavior

Docker container spins up with mounted volume and command run in working dir

Actual behavior

Docker container spins up but cannot run command in working directory due to volume not mounting

Information

I think this is an issue related to others I’ve seen with Windows path/filesystem quirks but I can’t figure out the magic combination.

I have both my C: and E: drive shared though Docker for Windows and I turned on File & Print Sharing for guest and public networks.

I have the same folder contents in both the C: and E: paths below.

Steps to reproduce the behavior

These all result in the same output below

  1. docker run -it -p 8080:3000 -v "e:/dev/docker/ExpressSite:/var/www" -w "/var/www" node npm start
  2. docker run -it -p 8080:3000 -v "E:/dev/docker/ExpressSite:/var/www" -w "/var/www" node npm start
  3. docker run -it -p 8080:3000 -v `pwd`:/var/www -w “/var/www” node npm start
  4. docker run -p 8080:3000 -v C:\Users\sean\docker\ExpressSite:/var/www -w "/var/www" node npm start
  5. docker run -p 8080:3000 -v "C:\Users\sean\docker\ExpressSite:/var/www" -w "/var/www" node npm start
npm info it worked if it ends with ok
npm info using npm@3.9.3
npm info using node@v6.2.1
npm ERR! Linux 4.4.12-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.2.1
npm ERR! npm  v3.9.3
npm ERR! path /var/www/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/var/www/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/var/www/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/npm-debug.log

So either the volume mounting is silently failing or I configured something incorrectly.

Update

Just read through this thread Volume mounts in windows does not work and it seems others are experiencing the same issues. I’ll keep an eye on any developments there.


(Sgwatdh) #2

As of Docker for Windows 1.12.0-rc2-beta16 (build: 4760) I can map volumes correctly and set my workspace. The following example works without issue on my system.

docker run -i -t -p 80:3000 -v //e/dev/docker/docker-site://var/www -w "//var/www" node //bin/bash

*Note I’m using Git Bash, not PowerShell which is why I have the // in my paths


(Kd2718) #3

this is great! I had the exact same issue. Adding // is what I was missing.