Docker与Node.js和Express.js

Ost*_*vyj 1 node.js express docker

我正在尝试将docker与我的节点应用程序一起使用,我的Dockerfile看起来像这样:

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"]
Run Code Online (Sandbox Code Playgroud)

但在尝试安装后运行docker buildnpm install运行后https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz出现错误:

The command 'bin/sh -c /src && npm install' returned a non-zero code : 1
Run Code Online (Sandbox Code Playgroud)

什么可能导致这样的问题?我已经尝试安装node-legacy而不是节点,但它不起作用

小智 5

试试这个:

# 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
Run Code Online (Sandbox Code Playgroud)