Reputation: 8177
I'm watching a Docker course from Pluralsight and I need to run a Docker source on a Docker container I just downloaded.
Even though I have package.json
file in the current path, it is not recognized.
Usuario@RE MINGW64 /d/node/ExpressSite
$ docker run -p 8080:3000 -v /$(pwd):/var/www -w "/var/www" node:4.4.5 npm start
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm ERR! Linux 4.4.12-boot2docker
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
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 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
Why the Pluralsight does the same and it works? What's wrong with my version?
Upvotes: 1
Views: 191
Reputation: 300
From official docs https://docs.docker.com/engine/userguide/containers/dockervolumes/:
If you are using Docker Machine on Mac or Windows, your Engine daemon has only limited access to your OS X or Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory. So, you can mount files or directories on OS X using.
docker run -v /Users/<path>:/<container path> ...
On Windows, mount directories using:
docker run -v /c/Users/<path>:/<container path> ...
So, you can create a directory inside C:\Users\<your_username>
(code
for example) with your code and mount it inside the container like so:
docker run -p 8080:3000 -v /c/Users/<your_username>/code:/var/www -w "/var/www" node:4.4.5 npm start
Please note that your code will be available inside the container in /var/www/
directory
pwd
returns /c/Users/<my_username>
. Try it yourself in Docker terminal.
You can use pwd
for convenience sake:
docker run -p 8080:3000 -v $(pwd)/code:/var/www -w "/var/www" node:4.4.5 npm start
Good luck with the course and Dockerize all the things!
Upvotes: 2