My docker container has no internet

+1 vote
My docker has no internet. The last time I used it was working fine. I’ve tried these following commands but not helping.

docker run -dns 8.8.8.8 base ping google.com

docker run base ping google.com

sysctl -w net.ipv4.ip_forward=1 - both on the host and on the container

All I get is unknown host google.com. Docker version 0.7.0

Any help will be appreciated..
Jul 31, 2018 in Docker by Hannah
• 14,070 points
1,462 views

5 answers to this question.

+1 vote
Best answer

Try resetting all the parameters

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

It will force docker to recreate the bridge and reinit all the network rules

answered Jul 31, 2018 by Kalgi
• 40,460 points

selected May 7 by Vardhan
0 votes

The most common reason for this error is if the container holds an invalid DNS. Then the container will not be able to resolve the domain name into IP addresses. And hence the ping google.com will also fail. Run the following command to check for DNS server:

cat /etc/resolv.conf
answered May 6 by Faziba
0 votes

Restarting Docker worked for me. Restart it using the following command:

service docker restart
answered May 6 by Aysha
0 votes

If you're running Docker on OSX, do the following:

docker-machine restart
<...wait for it to restart, which takes up to a minute...>
docker-machine env
eval $(docker-machine env)
answered May 6 by Nishant
0 votes

For me, it was the host's firewall. I had to allow DNS on the host's firewall. And also had to restart docker after changing the host firewall setting.

answered May 6 by Tina

Related Questions In Docker

0 votes
1 answer

How to configure my docker container to use a different logging driver?

When you start a docker container, you ...READ MORE

answered Jul 4 in Docker by Sirajul
• 25,700 points
23 views
0 votes
1 answer

Will I lose my data, when a docker container exists?

No, you won’t lose any data when ...READ MORE

answered Jul 30 in Docker by Kavya
24 views
+2 votes
6 answers
0 votes
2 answers

Can't access apache karaf docker container

To access karaf shell directly you can ...READ MORE

answered Aug 6, 2018 in Docker by Nilesh
• 6,880 points
193 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,540 points
156 views
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,110 points

edited Oct 16, 2018 by lina 4,300 views
+1 vote
11 answers