繁体   English   中英

apt-get在Dockerfile中不起作用

[英]apt-get not working in Dockerfile

解答 :我仍然不知道真正出了什么问题,但是在我重新启动了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安装行也不起作用时,这似乎也不成问题。

我不得不将其作为答案,因为我根本无法在评论中格式化

应该有更多的输出描述出了什么问题。 尝试在一个临时容器中迭代运行以下步骤:

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

我将这两行分开:

RUN apt-get update
RUN apt-get install -y nodejs

发现问题出在apt-get udpate

尝试了Abulla的建议,apt-get更新工作正常。

在我的Dockerfile中删除并重新输入RUN apt-get update行,一切正常。

我重新启动了docker并再次尝试,现在工作正常。

我尝试你的代码

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吗?

确保使用正确的Dockerfile。 如果是,请尝试其他图像。

我和Ubuntu Xenial出现了相同的问题,该问题是由于主机上运行了dnsmaq服务器所致。

解决方案是通过注释/etc/NetworkManager/NetworkManager.conf中dns=dnsmasq行并执行重新启动来禁用此服务器:

sudo service network-manager restart

希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM