[英]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.