node.js - 在 Kali Linux docker 映像上安装 NodeJS 时遇到问题
问题描述
我正在尝试基于 Kali Linux 基础映像创建一个 docker 映像,并且我需要安装 NodeJS 作为我的应用程序的依赖项。
这是我的 Dockerfile:
FROM kalilinux/kali-linux-docker
RUN apt-get update -y && \
apt-get dist-upgrade -y && \
apt-get autoremove -y && \
apt-get clean -y
RUN apt-get install curl -y
RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - \
&& apt-get install nodejs -y
RUN npm i -g npm
ENV NODE_ENV production
WORKDIR /root/app
COPY . .
RUN npm i
EXPOSE 4000
ENTRYPOINT ["npm", "start"]
但是,我在尝试安装 NodeJS 时遇到了以下错误:
Step 4/11 : RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && apt-get install nodejs -y
---> Running in a63e56802eba
## Installing the NodeSource Node.js 8.x LTS Carbon repo...
## Inspecting system...
## You don't appear to be running an Enterprise Linux based system,
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.
The command '/bin/sh -c curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && apt-get install nodejs -y' returned a non-zero code: 1
诚然,我对一些事情感到困惑......也就是说,我的印象是 NodeJS 已经安装在 Kali Linux 上(我有一个使用 Debian 64 位的 VirtualBox VM)。我试图安装kali-linux-all
元包,但 NodeJS/npm 似乎不存在。
我只是误解了 Docker 和/或 Kali Linux 的一些基本前提吗?有没有其他方法可以将 NodeJS 安装到我的容器中?
解决方案
我仍然不完全理解为什么 NodeJS 安装在我的 VM 上而不是基本的 Kali docker 映像上......但无论如何我确实设法解除了自己的阻塞。
首先,我从 nodesource 中提取了一个需要的 NodeJS 安装脚本rpm
——我发现了一个没有它也可以工作的不同脚本。但是,新脚本还要求我安装gnupg
.
这是我更新的 Dockerfile:
FROM kalilinux/kali-linux-docker
RUN apt-get update -y && \
apt-get dist-upgrade -y && \
apt-get autoremove -y && \
apt-get clean -y
RUN apt-get -y install curl gnupg
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install nodejs -y
RUN npm i -g npm
ENV NODE_ENV production
WORKDIR /root/app
COPY . .
RUN npm i
EXPOSE 4000
ENTRYPOINT ["npm", "start"]
推荐阅读
- angular - 如何在 Angular 中从外部网站访问资源?
- c# - 查找整数小于值的随机对象
- google-bigquery - 如何知道每次成功查询时 GCP BigQuery 中使用的 CPU/RAM 资源以及费用详情
- c++ - 带有类模板的附加非类型模板参数的可变参数方法的嵌套调用
- amazon-web-services - 无法通过我在 AWS 上的 centos ec2 实例访问互联网
- python - 如何减小seaborn箱形图的箱体尺寸并使图形适应新的箱体尺寸?
- android - Recyclerview的List Item移除后会被推送到下一个item
- office-addins - Outlook 加载项:如何在每 3 秒撰写一次时验证正文消息?
- python - 尝试将套接字连接到不同网络中的服务器会引发 WinError 10060
- java - 如何从默认的中央 maven 和其他公共存储库下载 maven jar 及其依赖项?