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
• 18,540 points
18,361 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
• 52,350 points

selected May 7, 2019 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, 2019 by Faziba
0 votes

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

service docker restart
answered May 6, 2019 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, 2019 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, 2019 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, 2019 in Docker by Sirajul
• 59,230 points
1,308 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, 2019 in Docker by Kavya
8,040 views
0 votes
1 answer

How to expose my docker container?

Hi@akhtar, To expose you container from outside you ...READ MORE

answered Apr 6, 2020 in Docker by MD
• 95,460 points
899 views
0 votes
1 answer

Is my data stored permanently inside docker container?

Hi@akhtar, Yes, whatever you stored inside docker container ...READ MORE

answered Apr 6, 2020 in Docker by MD
• 95,460 points
1,184 views
+2 votes
1 answer
+2 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
• 58,100 points
2,687 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,220 points

edited Oct 16, 2018 by lina 34,056 views
+15 votes
19 answers

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

you can run any command in a ...READ MORE

answered Dec 10, 2018 in Docker by Pramiti
1,229,344 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP