node.js - 使用 docker 安装 nodejs

标签 node.js centos docker

我尝试了以下方法将 Node 安装到 centos 盒子中,但是当它到达 ./configure 时出现错误

Step 6 : RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
---> Running in ebc71472544d
---> c97289348900
Removing intermediate container ebc71472544d
Step 7 : RUN cd /node-v0.10.28-linux-x64
---> Running in 3470f862c586
---> 1771d01a5da0
Removing intermediate container 3470f862c586
Step 8 : RUN ./configure
 ---> Running in 16a811766136
/bin/sh: ./configure: No such file or directory

我的 Dockerfile
#Install NodeJS
RUN cd /usr/src
RUN wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz
RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
RUN cd /node-v0.10.28-linux-x64
RUN ./configure
RUN make &&
RUN make install

我是否使用了使用 Dockerfile 将 Node 安装到 centos 的正确方法?

最佳答案

我假设这不是整个 Dockerfile,对吧?否则,您至少缺少一个 FROM .

尝试像这样更改最后 4 行:

RUN cd /node-v0.10.28-linux-x64 && ./configure
RUN cd /node-v0.10.28-linux-x64 && make
RUN cd /node-v0.10.28-linux-x64 && make install

或者像这样
RUN cd /node-v0.10.28-linux-x64 && ./configure && make && make install

据我所知,docker 正在运行每个 RUN命令作为单独的 shell,因此在下一个命令中不会记住仅更改目录。

这是一个用于测试的示例 Docker 文件:
FROM ubuntu

RUN cd /etc
RUN pwd

这是构建日志:
Step 0 : FROM ubuntu
 ---> 99ec81b80c55
Step 1 : RUN cd /etc
 ---> Running in a4c25ee340a8
 ---> 82ad93bdd18c
Removing intermediate container a4c25ee340a8
Step 2 : RUN pwd
 ---> Running in f535178df40c
/
 ---> 495c68757268

[编辑]

另一种选择是使用 WORKDIR , 像这样:
#Install NodeJS
WORKDIR /usr/src
ADD http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz .
RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
WORKDIR node-v0.10.28-linux-x64
RUN ./configure
RUN make &&
RUN make install

关于node.js - 使用 docker 安装 nodejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24072757/

相关文章:

permissions - 授予用户对目录 centos 的写权限

regex - 仅当具有给定名称的 Docker 容器不存在时,如何执行 Bash 命令?

node.js - 我有 TypeError [ERR_INVALID_CALLBACK] : Callback must be a function

node.js - node-cron 模块和 Heroku Scheduler 之间的区别

centos - Epel-Release 需要的 rpmlib

centos - SELINUX 中的 nis_enabled 是什么?

linux - 允许容器监听 80 端口的副作用

docker - 使用官方 docker 镜像和 .monetdb 文件时,用户 'monetdb' 的凭据无效

node.js - 使用 Meteor 从 Github Assets API 下载文件时出错

python - Python 的列表、元组和字典的 Node.js 等效数据类型