0

I run a Ubuntu docker on my machine but when i type the apt-get update command, it says :

root@50e964833537:/# apt-get update
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done        
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

I tried several "solutions" I found but still it doesn't work. I don't have access to any command in the docker because I can't update. I suppose because my Docker doesn't have access to Internet. How can I fix this ?

shizhz
  • 11,715
  • 3
  • 39
  • 49
Baptiste Arnaud
  • 2,522
  • 3
  • 25
  • 55
  • Is your host ubuntu 14 connected to the internet + is it able to resolve hostnames (dns) – lvthillo Apr 11 '17 at 13:32
  • Most probably your routes are wrong. Run `sudo route -n` and post the output. You can also run `ping 8.8.8.8` to ensure it's not a DNS issue. – Willian Paixao Apr 11 '17 at 13:32
  • I'm on a corporate network, it seems it's a DNS resolving problem. @Willian Paixao, I can't run any command in the docker it says "command not found". – Baptiste Arnaud Apr 11 '17 at 13:36
  • Regarding the corporate network, that's a valuable information. There might have a transparent Proxy, which blocks unauthenticated requests. Regarding the command not found, that's really strange, try remove and pull the image again. – Willian Paixao Apr 11 '17 at 13:39
  • I followed these steps : http://stackoverflow.com/questions/24151129/docker-network-calls-fail-during-image-build-on-corporate-network It still doesn't work. – Baptiste Arnaud Apr 11 '17 at 13:40
  • what is the output of `nm-tool | grep DNS` – lvthillo Apr 11 '17 at 13:48
  • If your server runs systemd it doesn't look at /etc/default/docker. Look at https://robinwinslow.uk/2016/06/23/fix-docker-networking-dns/ and at https://docs.docker.com/engine/admin/systemd/ (this explains also how you can set HTTP_PROXY if your corporate network is behind a proxy. – gile Apr 11 '17 at 13:49
  • I told you already : "nm-tool: command not found" This is why I need to do a apt-get update – Baptiste Arnaud Apr 11 '17 at 13:50
  • I changed the DNS IP adress to the one I have on my machine, it worked well : more /etc/resolv.conf nameserver 127.0.1.1 (on the docker) – Baptiste Arnaud Apr 11 '17 at 13:51
  • and on your host, not inside your docker – lvthillo Apr 11 '17 at 13:51

2 Answers2

1

SOLUTION :

I'm in a corporate network so I had to change the DNS ip adresses by follow these steps :

On the Host Machine :

  • nm-tool | grep DNS It will output the DNS servers
  • sudo nano /etc/default/docker and change the following line with DNS you got in the first step:
    • DOCKER_OPTS="--dns 'your_dns_server_1' --dns 'your_dns_server_2'"
  • Restart docker : sudo service docker restart
Baptiste Arnaud
  • 2,522
  • 3
  • 25
  • 55
0

For me it was our Internal VPN causing the issue. You should try turning it off once just to be sure.

This solution will work for you in this case.

pkill docker; iptables -t nat -F; ifconfig docker0 down; brctl delbr docker0

harpratap
  • 365
  • 6
  • 12