node.js - Docker 上的 Debian 映像 - 如何安装 Nodejs
问题描述
我正在编写一个 Dockerfile 以在 debian 服务器上运行 nodejs,但无法完成编译。dockerfile 是这样的:
FROM debian:9
RUN apt-get update -yq \
&& apt-get install curl gnupg -yq \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash \
&& apt-get install nodejs -yq \
&& apt-get clean -y
ADD . /app/
WORKDIR /app
RUN npm install
EXPOSE 2368
VOLUME /app/logs
CMD npm run start
我逐步执行以下说明
docker run --rm -it debian:latest
apt-get update
apt-get clean
apt-get install curl gnupg -yq
curl -sL https://deb.nodesource.com/setup_12.x | bash
最后一行尝试安装 lsb-release 包但出现错误。出现以下几行:
+ apt-get install -y lsb-release > /dev/null 2>&1
Error executing command, exiting
我执行命令
apt-get install -y lsb-release
最后几行是
Failed to fetch http://deb.debian.org/debian/pool/main/p/python3-defaults/python3-minimal_3.7.3-1_amd64.deb Bad header line Bad header data [IP: 151.101.122.133 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/python3.7/python3.7_3.7.3-2+deb10u1_amd64.deb Bad header line Bad header data [IP: 151.101.122.133 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
找了很久,不知道为什么要安装这个包,为什么不安装。
解决方案
可能是因为您有过时的源 PPA。
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /etc/apt/sources.list.d/*
sudo apt-get update
并尝试安装。详情在这里
推荐阅读
- ios - 在 ios 中接收通知时禁用应用程序徽章图标
- ubuntu - (Ubuntu, apache2, ufw) https 不可达
- html - 导航栏崩溃未按预期工作
- java - J3D 的材质设置会导致无纹理的对象
- .net - 如何在 Kubernetes 中部署 .net core?
- python - 使用 pandas 删除 csv 文件中的特定行
- javascript - 根据当前 viewZoom 设置可变 XYZ 源和缩放增量
- apache-spark - --master local[n] 和 --total-executor-core = n (Spark Standalone) 有什么区别?
- java - 从主机系统和 docker 容器读取文本文件会产生不同的结果
- html - CSS 翻译忽略 z-index