Dockerfile 是从 Centos:7 构建的 - 有没有办法指示安装 npm?
Dockerfile is building from Centos:7 - is there a way to instruct npm to be installed?
我必须使用现有的 Dockerfile,它从 Centos 7 生成一个 docker 图像。(FROM centos:7 是 Dockerfile 中的第一行。)
我需要能够 运行 'npm install' 和 'npm run' 命令在将 运行 安装此映像的容器中,但未安装 npm。我在网上找到的如何在 Centos 7 上安装 npm 的方法也不起作用,因为它们依赖于容器中也没有安装的 apt-get 之类的东西。没有 sudo 似乎也是一个问题。
有没有办法配置实际的 Dockerfile,构建镜像,并在正在构建的镜像上安装 npm?如果没有 - 我怎样才能在 docker 容器中安装 npm,它将 运行 这个 Centos7 图像?
答案:我将此添加到 Dockerfile:
RUN yum install -y epel-release
RUN yum install -y npm nodejs
CentOS 和(以及其他 EL 发行版)不使用 apt
,它们使用 yum
(或 dnf
)。不幸的是,npm
没有打包在 CentOS 的正常 repos 中,os 你必须安装 EPEL repo fist:
只需在您的 Dockerfile 中添加一个 yum
调用:
RUN yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y npm
我必须使用现有的 Dockerfile,它从 Centos 7 生成一个 docker 图像。(FROM centos:7 是 Dockerfile 中的第一行。)
我需要能够 运行 'npm install' 和 'npm run' 命令在将 运行 安装此映像的容器中,但未安装 npm。我在网上找到的如何在 Centos 7 上安装 npm 的方法也不起作用,因为它们依赖于容器中也没有安装的 apt-get 之类的东西。没有 sudo 似乎也是一个问题。
有没有办法配置实际的 Dockerfile,构建镜像,并在正在构建的镜像上安装 npm?如果没有 - 我怎样才能在 docker 容器中安装 npm,它将 运行 这个 Centos7 图像?
答案:我将此添加到 Dockerfile:
RUN yum install -y epel-release
RUN yum install -y npm nodejs
CentOS 和(以及其他 EL 发行版)不使用 apt
,它们使用 yum
(或 dnf
)。不幸的是,npm
没有打包在 CentOS 的正常 repos 中,os 你必须安装 EPEL repo fist:
只需在您的 Dockerfile 中添加一个 yum
调用:
RUN yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y npm