1

I'm trying to use docker with my node application, my Dockerfile looks like this:

RUN     apt-get update
RUN     apt-get -y install build-essential
RUN     apt-get install -y nodejs
RUN     apt-get install -y npm

ADD     . /src
RUN     cd /src && npm install

EXPOSE  8080

CMD     ["node","/src/app.js"]

but after running docker build when npm install is running after trying to install https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz I get an error:

The command 'bin/sh -c /src && npm install' returned a non-zero code : 1

What can cause such an issue? I've already tried to install node-legacy instead of node and it didn't work

4
  • Is the typo "regisrty" just here on SO, or is that causing your problem? Commented Oct 7, 2015 at 15:21
  • what commands did you give to build and start the image ? Commented Oct 7, 2015 at 16:07
  • the TYPO was my mistake while writing this post, I've fixed it. I'm not able to start the image as it's not building. The npm install returns an error after successfully installing a bunch of extra modules Commented Oct 7, 2015 at 16:16
  • would you not pass any arg to your npm install ? Is this the complete dockerfile or the partial one ? You could consider using a base image "FROM ubuntu:14.04" or something similar ... what commands did you give to build and start the image ? npm install should in one of the layers when the image is getting built. Commented Oct 7, 2015 at 16:20

1 Answer 1

5

Try this:

# put this line on your code (if you are using ubuntu)
# this make a link from nodejs to node to add compatibility on ubuntu OS
RUN ln -s /usr/bin/nodejs /usr/bin/node

# set your current directory with WORKDIR
WORKDIR /src
RUN sudo npm install
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.