答案:我仍然不知道出了什么问题,但是在我重新启动docker并再次运行它(相同的dockerfile,同样的所有内容)后,它运行正常。
我在Windows上使用Docker而我的Dockerfile是
FROM ubuntu:15.04
COPY . /src
RUN apt-get update
RUN apt-get install -y nodejs
...etc
但是当我尝试构建图像时,我得到了
WARN[0001] SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories
...
Step 3: RUN apt-get -y update
--> Using cache
--->ccd4120f98dd
Removing intermediate container 255796bdef29
Step 4: RUN apt-get install -y nodejs
---> Running in f6c1d5a54c7a
Reading package lists...
Reading dependency tree...
Reading state information...
E: Unable to locate package nodejs
INFO[0029] The command [/bin/sh -c apt-get install -y nodejs] returned a non-zero code:100
apt-get有效,但是当我尝试将其他apt-get安装行放在那些不能正常工作的地方时,它似乎不会出现问题。
答案 0 :(得分:8)
我不得不把它作为一个答案,因为我无法在评论中进行格式化
应该有更多输出描述出错的地方。尝试在临时容器内迭代运行这些步骤:
docker run --rm -it ubuntu:15.04 bash -l
apt-get update
apt-get install -y nodejs
这能否为您提供更多关于什么是破坏的信息?
<强>更新强>
尝试并迭代它:
FROM ubuntu:15.04
RUN apt-get update && apt-get install -y nodejs
答案 1 :(得分:3)
我把这两行分开了:
RUN apt-get update
RUN apt-get install -y nodejs
发现问题出在apt-get udpate
。
尝试了Abulla的建议,apt-get update运行良好。
删除并重新输入我的Dockerfile中的RUN apt-get update
行,一切正常。
答案 2 :(得分:2)
我重新启动了docker并再次尝试,现在它工作正常。
答案 3 :(得分:0)
我尝试你的代码
FROM ubuntu:15.04
COPY . /src
RUN apt-get update &&
RUN apt-get install -y nodejs
对我来说一切正常
当我删除-y标志时,我遇到了同样的问题
FROM ubuntu:15.04
COPY . /src
RUN apt-get update
RUN apt-get install nodejs
您使用的是正确的Dockerfile吗?
答案 4 :(得分:0)
确保使用正确的Dockerfile。如果是,请尝试使用其他图像。
答案 5 :(得分:0)
我遇到了同样的问题Ubuntu Xenial
,问题是由于我的主机上运行了dnsmaq
服务器。
解决方案是通过在 /etc/NetworkManager/NetworkManager.conf 中注释dns=dnsmasq
行来禁用此服务器并执行重启:
sudo service network-manager restart
希望这有帮助!