apt-get在Dockerfile中不起作用
解答 :我仍然不知道什么是错误的,但是在重新启动docker并重新运行后(同样的dockerfile,一切都一样),它工作正常。
我在Windows上使用Docker,我的Dockerfile是
FROM ubuntu:15.04 COPY . /src RUN apt-get update RUN apt-get install -y nodejs ...etc
但是当我试图build立我得到的图像
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
这是否给你更多的信息是什么突破?
UPDATE
试试这个,并迭代它:
FROM ubuntu:15.04 RUN apt-get update && apt-get install -y nodejs
我重新启动docker,并再次尝试,现在它工作正常。
我分开了两行:
RUN apt-get update RUN apt-get install -y nodejs
发现问题是与apt-get udpate
。
尝试Abullabuild议,apt-get更新工作正常。
删除并重新input我的Dockerfile中的RUN apt-get update
行,并且一切正常。
我尝试你的代码
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
希望这个帮助!