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
• 16,730 points
2,153 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
• 42,540 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
• 39,540 points
35 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
53 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
245 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,940 points
232 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 5,415 views
+1 vote
11 answers

How can I run a ‘docker exec’ command inside a docker container?

Use bash with -c docker exec -it CONTAINER_ID ...READ MORE

answered Dec 10, 2018 in Docker by Kiyara
129,128 views