Could not resolve 'archive.ubuntu.com' [14.04.1 LTS]

I’m using Ubuntu server 14.04.1 LTS and have installed Docker 1.4.1 by adding the official Docker repo to apt. So far so good. After installation I have added my user to the Docker group, so I’m able to run docker with my own user. Docker version output is:

Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8
OS/Arch (client): linux/amd64
Server version: 1.4.1
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): 5bc2ff8

Now my problem: when I run the docker command below, the container is unable to connect to the Ubuntu host. Some Googling told me that it has to do with IP6, but unfortunately I was unable to fix this.

Docker command:

docker run --name="test" ubuntu:14.04 apt-get update

And the corresponding output:

Unable to find image 'ubuntu:14.04' locally
ubuntu:14.04: The image you are pulling has been verified
53f858aaaf03: Pull complete
837339b91538: Pull complete
615c102e2290: Pull complete
b39b81afc8ca: Pull complete
511136ea3c5a: Already exists
Status: Downloaded newer image for ubuntu:14.04
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...
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.

I’m kind of running out of options. How can I fix this? The server contains two NICs and is also acting as a router for my local network.

1 Like

Try:

docker run --name="test-1" ubuntu:14.04 ping 8.8.8.8

If this does not work, you can use: docker-enter test-1 to access the console of the container “test-1” and troubleshoot the networking.

To install docker-enter run:

docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter

Thanks; I have installed docker-enter and I’m able to access test-1. The ifconfig output is as below, but what’s wrong? I am unable to ping 8.8.8.8.

eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:04
inet addr:172.17.0.4 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:4/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:36 errors:0 dropped:0 overruns:0 frame:0
TX packets:256 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2928 (2.9 KB) TX bytes:24258 (24.2 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)

Well, looks like adding “–ip-masq=true” to the docker daemon solved it.

I thought --ip-masq=true was the default? mildly confused.

For future people with the same problem - I had this and found that I had to stop and start boot2docker to reset it.

Indeed, it is. And the problem is os related. Please see my new post: Docker and iptables configuration @startup

In short: on Ubuntu server, the firewall section is loaded AFTER the Docker daemon starts. Since Docker is adding stuff to iptables, these changes get lost during boot-up.

Thanks! This worked for me!

Yes, I added the ip-masq thing to the Docker options in /etc/default/docker:

DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --ip-masq=true"

and then restarted the docker service:

sudo /etc/init.d/docker restart

So yes, --ip-masq=trueworked for me, too. Thanks!