Docker CentOS映像NodeJS

时间:2017-09-29 16:58:16

标签: node.js docker centos7

我正在尝试在Docker CentOs上安装NodeJS: 下面是我的dockerfile:

FROM centos:7.3.1611

ADD https://rpm.nodesource.com/setup_8.x /root/
#RUN curl -sL https://rpm.nodesource.com/setup_8.x
RUN bash /root/setup_8.x ;\  
yum -y install nodejs ;\
yum -y install java-1.8.0-openjdk

#removed the rest of code

我使用下面的内容来构建容器:

docker-compose build --no-cache

输出如下:

Building test
Step 1/3 : FROM centos:7.3.1611
 ---> 67591570dd29
Step 2/3 : ADD https://rpm.nodesource.com/setup_8.x /root/


 ---> 92d4f540a9e8
Removing intermediate container d4cef3605bdd
Step 3/3 : RUN bash /root/setup_8.x ;  yum -y install nodejs ;  yum -y install java-1.8.0-openjdk
 ---> Running in 2c331b5211c7

## Installing the NodeSource Node.js 8.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Your distribution, identified as "centos-release-7-3.1611.el7.centos.x86_64", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support

似乎问题是'exec_cmd_nobail'curl -sLf -o / dev / null'$ {RELEASE_URL}''在设置脚本中返回非零输出,任何提示?问题不像一周前那样我试过,我猜Docker Centos图像有变化吗?

=======================

  • 解决!答案在评论中。谢谢!

1 个答案:

答案 0 :(得分:-1)

这是我尝试许多不同方式后使其工作的方式:

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
RUN source $HOME/.bashrc && nvm install 12.14.1

RUN ln -s $HOME/.nvm/versions/node/v12.14.1/bin/node /usr/bin/node
RUN ln -s $HOME/.nvm/versions/node/v12.14.1/bin/npm /usr/bin/npm

RUN node -v
RUN npm -v