简体   繁体   English

在Ubuntu 14.04主机上的官方ubuntu docker映像中下载失败

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

Trying to build a new docker image from the official ubuntu:12.04 and ubuntu:latest on a Ubuntu 14.04.02 Trusty Server. 尝试从Ubuntu 14.04.02 Trusty Server上的官方ubuntu:12.04ubuntu:latest构建新的docker映像。

It is not a DNS problem. 这不是DNS问题。 It's working fine. 一切正常。 I'm not behind a proxy. 我没有代理人。 I get the network connection, but can't download the files. 我已建立网络连接,但无法下载文件。 Always get 404: file not found , but the url is correct. 总会得到404: file not found ,但网址正确。

Finally Tried the following Dockerfile to prove my point: 最后,尝试了以下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

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

And got the following output: 并得到以下输出:

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

This output shows that: 此输出显示:

  1. The url is valid and accessible. 网址有效且可访问。 The ADD command was able to download the file successfully. ADD命令能够成功下载文件。
  2. The network connection in the container is OK, since it is able to ping the remote host. 容器中的网络连接正常,因为它可以ping通远程主机。
  3. The container is able to resolve the DNS name. 容器能够解析DNS名称。

Apt-get update shows the exact same problem, as in the following excerpt output from the command docker run ubuntu:12.04 apt-get update : 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]

For information, the docker version command output shows: 有关信息, 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

Thanks in advance. 提前致谢。

EDIT: 编辑:

Ufw was inactive. Ufw处于非活动状态。 Thanks Thomas. 谢谢托马斯。

It was a network IPS behaving oddly at the edge. 这是一个处于边缘状态的网络IPS。 Network support fixed and it is now working OK. 网络支持已修复,现在可以正常运行。

There is an important difference to understand when docker build executes a ADD instruction and when it executes a RUN instruction. 了解docker build何时执行ADD指令和何时执行RUN指令之间存在重要区别。

  • with the ADD instruction, the download takes place from the docker host and then is pushed into the build context. 使用ADD指令,从Docker主机进行下载,然后将其推送到构建上下文中。
  • with the RUN instruction, the download takes place from within a running container. 使用RUN指令,可从正在运行的容器中进行下载。

This difference can explain why it works with one and fails with the other. 这种差异可以解释为什么它只能与一个一起使用而不能与另一个一起使用。

Since your host is Ubuntu, make sure you followed the Docker installation instructions regarding the ufw firewall which says: 由于您的主机是Ubuntu,因此请确保您遵循有关ufw防火墙的Docker安装说明,其中包括:

If you use UFW (Uncomplicated Firewall) on the same host as you run Docker, you'll need to do additional configuration. 如果在运行Docker的同一主机上使用UFW(非复杂防火墙),则需要进行其他配置。 Docker uses a bridge to manage container networking. Docker使用网桥来管理容器网络。 By default, UFW drops all forwarding traffic. 默认情况下,UFW丢弃所有转发流量。 As a result, for Docker to run when UFW is enabled, you must set UFW's forwarding policy appropriately. 因此,要在启用UFW时运行Docker,必须适当设置UFW的转发策略。

Also if you want to investigate from within a container the issue and easily try out commands to figure the problem out, I suggest you open a bash shell in a container created from that same ubuntu image: 另外,如果您想从容器中调查问题并轻松地尝试找出问题的方法,建议您在从同一ubuntu映像创建的容器中打开bash shell:

docker run -it ubuntu /bin/bash -l

and from there you will be able to diagnose the issue, for instance with: 然后您可以从那里诊断问题,例如:

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