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,300 points

edited Oct 11, 2018 by Kalgi 5,807 views

4 answers to this question.

+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,240 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,220 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, 2019 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, 2019 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,300 points
933 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
• 10,620 points
1,688 views
0 votes
1 answer

How do I push a docker image to a private repository?

Here is what you can do. Just try ...READ MORE

answered Sep 19, 2018 in DevOps & Agile by Damon Salvatore
• 5,980 points
1,388 views
+2 votes
1 answer
+2 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
• 58,020 points
2,714 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,240 points
555 views
+5 votes
1 answer

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 27, 2018 in DevOps & Agile by Atul
• 10,240 points
3,461 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP