Communication between containers and wider world

Dear all,
The issue has been resolved by myself recently. Totally, i’ve been fighting this problem on and off for almost one week, fortunately, some posts in github, stackoverflow, askubuntu, etc, gave me insights. Hope my way would be helpful to you.
Step1: Check the DNS server you’re using through typing:
mingchen@mingchen-HP:~$ nm-tool | grep DNS
In my terminal, I got;
DNS: 127.0.0.1
DNS: 8.8.8.8
DNS: 172.20.1.4
DNS: 172.20.1.6

Step2: copy the above DNS server to the '/etc/docker/daemon.json’
$ sudo gedit /etc/docker/daemon.json
just like the following format:

{
“dns”: [“8.8.8.8”,“172.20.1.4”,“172.20.1.6”, “127.0.0.1”,“8.8.4.4”]
}
Step3: restart docker service.
$ sudo service docker restart

Step4: Run a docker container and test it!
The following is my test result:

root@95ce75c5dbc0:/# ping baidu.com
PING baidu.com (123.125.114.144) 56(84) bytes of data.
64 bytes from 123.125.114.144: icmp_seq=1 ttl=51 time=38.0 ms
64 bytes from 123.125.114.144: icmp_seq=2 ttl=51 time=37.7 ms
64 bytes from 123.125.114.144: icmp_seq=3 ttl=51 time=37.8 ms

Step5; Hope my post is helpful to you.
:blush:

1 Like