Docker on ubuntu 14.04 Could not resolve 'archive.ubuntu.com'
2016-04-01 16:25:54
Starry
  • 访问次数: 5
  • 注册日期: 2016-03-22
  • 最后登录: 2016-04-05

新创建的容器,镜像是ubuntu:latest


#  apt-get update

出错:

Err http://archive.ubuntu.com trusty InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://archive.ubuntu.com trusty-security InRelease
Err http://archive.ubuntu.com trusty Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-security Release.gpg
  Could not resolve 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease 
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease 
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease 
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Could not resolve 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

宿主机是可以apt-get 的,没有问题,如果容器指定了--net=host模式,则也可以


我也过网上不少方法,但都不起作用

/etc/resolv.conf


# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1


 /etc/default/docker

#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" 去掉了前面的#号



主机   ip_forward=1   

docker0   Link encap:以太网  硬件地址 56:84:7a:fe:97:99  
          inet 地址:172.17.42.1  广播:0.0.0.0  掩码:255.255.0.0
          inet6 地址: fe80::5484:7aff:fefe:9799/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
          接收数据包:1599 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:7233 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:0
          接收字节:93594 (93.5 KB)  发送字节:4539987 (4.5 MB)


vethef815a5 Link encap:以太网  硬件地址 de:51:c1:75:c5:73  
          inet6 地址: fe80::dc51:c1ff:fe75:c573/64 Scope:Link
          UP BROADCAST RUNNING  MTU:1500  跃点数:1
          接收数据包:48 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:71 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:0
          接收字节:3648 (3.6 KB)  发送字节:12120 (12.1 KB)

virbr0    Link encap:以太网  硬件地址 3a:76:de:ac:cd:17  
          inet 地址:192.168.122.1  广播:192.168.122.255  掩码:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  跃点数:1
          接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:0
          接收字节:0 (0.0 B)  发送字节:0 (0.0 B)


已安装bridge-util 



容器:

root@af7ebc3eeb9e:/# ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:05  
          inet addr:172.17.0.5  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:acff:fe11:5/64 Scope:Link
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          RX packets:73 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:12663 (12.6 KB)  TX bytes:3648 (3.6 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

把自己尝试的一些修改都写上来了,有些乱,困扰了好几天,仍然不行,求大神救命,拜谢!!!