簡體   English   中英

在Ubuntu 14.04主機上的官方ubuntu docker映像中下載失敗

[英]Download failure within official ubuntu docker images on Ubuntu 14.04 host

嘗試從Ubuntu 14.04.02 Trusty Server上的官方ubuntu:12.04ubuntu:latest構建新的docker映像。

這不是DNS問題。 一切正常。 我沒有代理人。 我已建立網絡連接,但無法下載文件。 總會得到404: file not found ,但網址正確。

最后,嘗試了以下Dockerfile來證明我的觀點:

FROM ubuntu
ADD 'http://ftp.unicamp.br/pub/apache/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz' /
COPY wget /usr/bin/
COPY ping /bin/
COPY libidn.so.11 /usr/lib/x86_64-linux-gnu/
RUN ping -c 4 ftp.unicamp.br
RUN wget http://ftp.unicamp.br/pub/apache/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz
RUN tar zxf apache-tomcat-7.0.62.tar.gz

跑命令docker build --no-cache=true -t raoni/tomcat:0.1 .

並得到以下輸出:

Sending build context to Docker daemon 1.885 MB
Sending build context to Docker daemon
Step 0 : FROM ubuntu
 ---> 6d4946999d4f
Step 1 : ADD http://ftp.unicamp.br/pub/apache/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz /
Downloading [==================================================>] 8.825 MB/8.825 MB
 ---> 6d13d9232ebb
Removing intermediate container a3c80c01a112
Step 2 : COPY wget /usr/bin/
 ---> ba1d72d7b503
Removing intermediate container c004c20c396e
Step 3 : COPY ping /bin/
 ---> 59fb0419c477
Removing intermediate container c2f3d5035458
Step 4 : COPY libidn.so.11 /usr/lib/x86_64-linux-gnu/
 ---> 66cf1b0c13cc
Removing intermediate container 3dccacf5c992
Step 5 : RUN ping -c 4 ftp.unicamp.br
 ---> Running in 62bbdda28ef6
PING ftp.unicamp.br (143.106.10.149) 56(84) bytes of data.
64 bytes from ftp.unicamp.br (143.106.10.149): icmp_seq=1 ttl=52 time=31.6 ms
64 bytes from ftp.unicamp.br (143.106.10.149): icmp_seq=2 ttl=52 time=31.7 ms
64 bytes from ftp.unicamp.br (143.106.10.149): icmp_seq=3 ttl=52 time=31.8 ms
64 bytes from ftp.unicamp.br (143.106.10.149): icmp_seq=4 ttl=52 time=32.0 ms

--- ftp.unicamp.br ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 31.609/31.818/32.067/0.211 ms
 ---> cffab8d12f25
Removing intermediate container 62bbdda28ef6
Step 6 : RUN wget http://ftp.unicamp.br/pub/apache/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz
 ---> Running in c38cf1dfb7a9
--2015-06-23 22:36:17--  http://ftp.unicamp.br/pub/apache/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz
Resolving ftp.unicamp.br (ftp.unicamp.br)... 143.106.10.149
Connecting to ftp.unicamp.br (ftp.unicamp.br)|143.106.10.149|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2015-06-23 22:36:17 ERROR 404: Not Found.

The command '/bin/sh -c wget http://ftp.unicamp.br/pub/apache/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz' returned a non-zero code: 8

此輸出顯示:

  1. 網址有效且可訪問。 ADD命令能夠成功下載文件。
  2. 容器中的網絡連接正常,因為它可以ping通遠程主機。
  3. 容器能夠解析DNS名稱。

Apt-get update顯示了完全相同的問題,如以下命令摘錄自docker run ubuntu:12.04 apt-get update命令輸出:

Err http://archive.ubuntu.com precise/main Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://archive.ubuntu.com precise/restricted Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://archive.ubuntu.com precise/universe Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://archive.ubuntu.com precise/universe amd64 Packages
  404  Not Found [IP: 91.189.91.13 80]

有關信息, docker version命令輸出顯示:

root@vm:~/docker/test# docker version
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): linux/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64

提前致謝。

編輯:

Ufw處於非活動狀態。 謝謝托馬斯。

這是一個處於邊緣狀態的網絡IPS。 網絡支持已修復,現在可以正常運行。

了解docker build何時執行ADD指令和何時執行RUN指令之間存在重要區別。

  • 使用ADD指令,從Docker主機進行下載,然后將其推送到構建上下文中。
  • 使用RUN指令,可從正在運行的容器中進行下載。

這種差異可以解釋為什么它只能與一個一起使用而不能與另一個一起使用。

由於您的主機是Ubuntu,因此請確保您遵循有關ufw防火牆的Docker安裝說明,其中包括:

如果在運行Docker的同一主機上使用UFW(非復雜防火牆),則需要進行其他配置。 Docker使用網橋來管理容器網絡。 默認情況下,UFW丟棄所有轉發流量。 因此,要在啟用UFW時運行Docker,必須適當設置UFW的轉發策略。

另外,如果您想從容器中調查問題並輕松地嘗試找出問題的方法,建議您在從同一ubuntu映像創建的容器中打開bash shell:

docker run -it ubuntu /bin/bash -l

然后您可以從那里診斷問題,例如:

route
cat /etc/resolv.conf
apt-get update && apt-get -y install traceroute telnet
traceroute ftp.unicamp.br
telnet ftp.unicamp.br 80

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM