Reputation: 6121
Working through the very simple example in "Dockerizing your Node.js Applications" I get failures in the docker build step.
https://nodesource.com/blog/dockerizing-your-nodejs-applications
steve@steve-docker:~/projects/docker-tutorial$ docker build -t "myapp" .
Sending build context to Docker daemon 54.27 kB
Step 0 : FROM nodesource/node:4.0
4.0: Pulling from nodesource/node
7a42f1433a16: Already exists
3d88cbf54477: Already exists
f7de320a63d8: Already exists
25ca017f7153: Already exists
96682a971c4a: Already exists
51b426f992a7: Already exists
7c37012fed92: Already exists
fd06eadac973: Already exists
9763c03a384a: Already exists
e4dca69ac79f: Already exists
Digest: sha256:e0f4a2cef10482abf99a3dda475db22b9f1b3e0441ff5f4c40aa58820cfcaec9
Status: Downloaded newer image for nodesource/node:4.0
---> e4dca69ac79f
Step 1 : ADD package.json package.json
---> Using cache
---> cf6b38206c03
Step 2 : RUN npm install
---> Running in fc2c50798256
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
The already exists are no doubt as I ran it beforehand
I don't know enough yet about docker to be able to debug within the context that docker build is running but npm install works fine in the host context (at command prompt). My guess is something is wrong with the nodesource/node image
I'm running Ubuntu 15.0 x64 in VirtualBox on Windows 10.
Upvotes: 3
Views: 3859
Reputation: 251
Run npm install directly by navigating to the project root folder. Now run the docker build again - now it will not hang. The reason could be docker unable to create node_modules folder when we run the build command or could be we have to pass permission while running build command
Upvotes: 1
Reputation: 1085
please follow these steps:
FROM nodesource/node:4.0
ADD package.json package.json
RUN npm install
ADD . .
CMD ["node","app.js"]
sudo docker build -t "myapp" .
sudo docker run -it "myapp"
and you should see something like this:
Upvotes: 0