I am struggling since two days with the following problem.
Packages management systems fail when I try to run them in order to build a new container image, I tried with alpine:latest and ubuntu:latest. I get the same behavior if I try to use them from a running container, even if I use the --network host
option.
For example if I try to build the following container:
FROM alpine:latest
RUN apk update
like this:
docker build --no-cache -t test .
I get:
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/main: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.b89edf6e.tar.gz: No such file or directory
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/community: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.737f7e01.tar.gz: No such file or directory
and with ubuntu:
FROM ubuntu:latest
RUN apt-get update
I get:
Sending build context to Docker daemon 3.954MB
Step 1/2 : FROM ubuntu:latest
---> 47b19964fb50
Step 2/2 : RUN apt-get update
---> Running in 4c637396e7be
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Could not connect to 127.0.0.1:3000 (127.0.0.1). - connect (111:Connection refused)
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Could not connect to 127.0.0.1:3000 (127.0.0.1). - connect (111:Connection refused)
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Unable to connect to 127.0.0.1:3000:
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Unable to connect to 127.0.0.1:3000:
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Could not connect to 127.0.0.1:3000 (127.0.0.1). - connect (111: Connection refused)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Unable to connect to 127.0.0.1:3000:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Unable to connect to 127.0.0.1:3000:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Could not connect to 127.0.0.1:3000 (127.0.0.1). connect (111: Connection refused)
W: Some index files failed to download. They have been ignored, or old ones used instead.
Removing intermediate container 4c637396e7be
---> e41da39b1a0d
Successfully built e41da39b1a0d
Successfully tagged test:latest
I am working with Docker version 18.09.3, build 774a1f4, on a ubuntu 16.04 host. My system runs behind a router. I already tried the strategies suggested in this answer and also the one in this answer without any luck. Even stranger if I ping from the adiazmor/docker-ubuntu-with-ping as follow:
docker run --rm -it adiazmor/docker-ubuntu-with-ping
root@a774331799d3:/# ping google.com
PING google.com (216.58.205.46): 56 data bytes
64 bytes from 216.58.205.46: icmp_seq=0 ttl=53 time=44.976 ms
64 bytes from 216.58.205.46: icmp_seq=1 ttl=53 time=43.661 ms
64 bytes from 216.58.205.46: icmp_seq=2 ttl=53 time=43.471 ms
64 bytes from 216.58.205.46: icmp_seq=3 ttl=53 time=44.066 ms
64 bytes from 216.58.205.46: icmp_seq=4 ttl=53 time=43.849 ms
It works but then apt-get update fails as before. I am running out of ideas. Any help is appreciated.
Update: It seems that some containers are able to find the proper DNS server while others are not.
Indeed if I run:
docker run --rm -i busybox nslookup google.com
It doesn't work:
Unable to find image 'busybox:latest' locallylatest: Pulling from library/busybox
697743189b6d: Pull complete
Digest: sha256:061ca9704a714ee3e8b80523ec720c64f6209ad3f97c0ff7cb9ec7d19f15149f
Status: Downloaded newer image for busybox:latest
Server: 8.8.8.8
Address: 8.8.8.8:53
Non-authoritative answer:
Name: google.com
Address: 2a00:1450:4002:807::200e
*** Can't find google.com: No answer
but If I run:
docker run --rm -it tutum/dnsutils nslookup google.com
it works:
Unable to find image 'tutum/dnsutils:latest' locally
latest: Pulling from tutum/dnsutils
a3ed95caeb02: Pull complete
0d4f8675aa34: Pull complete
7cf67d95acf6: Pull complete
56692d2aae61: Pull complete
349ad02ed73a: Pull complete
Digest: sha256:d2244ad47219529f1003bd1513f5c99e71655353a3a63624ea9cb19f8393d5fe
Status: Downloaded newer image for tutum/dnsutils:latest
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: google.com
Address: 216.58.205.78