vt_todd
vt_todd

Reputation: 304

Error running Docker node container on Windows 10

I am new to Docker and attempting to run through a few simple examples on both my Windows 10 PC and my Mac simulteneously. The example below works fine on Mac but not on the PC.

Docker Toolbox is installed and I've downloaded the official Node image from DockerHub. I used Express to create a simple Javascript-based site using Handlebars that works fine if I execute npm start locally from the host.

When I attempt to start the container with the following command I get an error on the Windows machine:

$  docker run -p 8080:3000 -v $(pwd):/var/www -w "/var/www" node 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.27-boot2docker
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.2.0
npm ERR! npm  v3.10.9
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

The same command works fine on the Mac and I can hit http://host-ip:8080 no problem.

Again, this is a simple example that should work on both platforms, wondering if the error may be a known difference in the way Docker Toolbox works on each platform, or perhaps a syntax error in the command.

Any help is appreciated.

Upvotes: 1

Views: 724

Answers (1)

VonC
VonC

Reputation: 1324657

With Docker Toolbox on Windows (involving VirtualBox), make sure your $(pwd) is a path starting with C:\Users\<myLogin>: only this folder is pre-shared and auto-mounted by VirtualBox.

You can try a docker run with a ls /var/www as CMD to check if /var/www does reflect your $(pwd) content.

docker run -p 8080:3000 -v $(pwd):/var/www -w "/var/www" node ls

Upvotes: 2

Related Questions