使用Docker安装Node.js失败

在使用Docker时,当执行docker compose up –build命令时,由于安装node-js时出现错误,因此将其保存下来以备将来使用。

错误部分

Dockerfile中

RUN apt-get install -y gnupg \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs

错误内容 (Mistake content)

Error executing command, exiting

处理方法

步骤1:将错误部分注释掉。

# RUN apt-get install -y gnupg \
# && curl -sL https://deb.nodesource.com/setup_10.x | bash - \
# && apt-get install -y nodejs

请再次运行STEP2 docker compose up –build。

进入 STEP3 的 Docker 容器

docker exec -ti コンテナ名 bash

第四步,删除源代码。

rm -rf /var/lib/apt/lists/*
rm -rf /etc/apt/sources.list.d/*
apt-get update

参考:https://askubuntu.com/questions/1141035/error-executing-command-exiting
由于没有sudo权限,所以以无sudo权限的方式执行。

执行被注释的命令

RUN apt-get install -y gnupg
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs

结束了

关于原因,我还不太清楚,但总的来说,现在已经可以动了!

bannerAds