Unable to build docker image

+3 votes

This is the dockerfile I'm using to build the docker image:

FROM mhart/alpine-node:base-6

MAINTAINER techhadmin
COPY ./package.json src/
RUN cd src && npm install 
COPY . /src 
WORKDIR /src
EXPOSE 3000
CMD ["npm", "start"]

But I get this error:

/bin/sh: npm: not found
The command '/bin/sh -c cd src && npm install' returned a non-zero code: 127

Any help will be appreciated..

Mar 26, 2018 in DevOps & Agile by ajs3033
• 7,000 points

edited Oct 11, 2018 by Kalgi 430 views

4 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote

See if this helps:

https://hub.docker.com/r/mhart/alpine-node/

try not using base tags:

# If you need npm, don't use a base tag

# RUN npm install

So don't use base-6 tag and change FROM image to something like 7

FROM mhart/alpine-node:7
answered Mar 26, 2018 by Atul
• 10,190 points
+1 vote

It looks like the dev dependencies were not installed, you might have the NODE_ENV variable set to production.

answered Oct 11, 2018 by lina
• 8,100 points

edited Oct 17, 2018 by lina
0 votes

The base image that you're using is 6 and probably you need another version. try using base-7. The reason for this error is, since its using the wrong base image, it creates a wrong path. ​

answered Apr 8 by Anshul
0 votes

There is another Cheap workaround(not suggested). You can remove the lines that create errors from the Dockerfile and execute those commands manually. But of course this is not recommended, the entire point of Dockerfile is undermined.

answered Apr 8 by Anshul

Related Questions In DevOps & Agile

0 votes
1 answer
0 votes
1 answer

unable to build .Net project using NUGet

you just need the developer pack for ...READ MORE

answered Apr 3, 2018 in DevOps & Agile by ajs3033
• 7,000 points
105 views
0 votes
1 answer

Error: Unable to access elasticsearch in docker for windows

This is simple, just follow the below ...READ MORE

answered Sep 3, 2018 in DevOps & Agile by Sophie may
• 9,050 points
25 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,100 points
56 views
0 votes
1 answer

Is it possible to preserve local ivy repository in Bluemix BUILD & DEPLOY?

You're right--the pipeline spins up a new ...READ MORE

answered Jul 19, 2018 in DevOps & Agile by Atul
• 10,190 points
18 views
+5 votes
2 answers

How to program and get the Digital Ocean ID of the current Droplet from within the Droplet?

You can run curl http://169.254.169.254/metadata/v1/id within the ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by Atul
• 10,190 points
118 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.