My docker container has no internet

0 votes

It was working fine before, but it has now stopped. 

I tried the following commands without success:

docker run -dns 8.8.8.8 google.com base ping

base docker ping google.com

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

I only get the unknown host google.com. 

Version 0.7.0 of Docker


 

Any suggestions?

Jan 2, 2023 in DevOps on Cloud by Damonlang
• 1,230 points
4,737 views

1 answer to this question.

0 votes

To begin, run cat /etc/resolv.conf in the docker container. If it uses an invalid DNS server, such as nameserver 127.0.x.x, the container will be unable to resolve domain names into IP addresses, causing ping google.com to fail.

The second step is to run cat /etc/resolv.conf on the host machine. Every time a container is started, Docker copies the host's /etc/resolv.conf to the container. If the host's /etc/resolv.conf is incorrect, the docker container will be as well.

If you discover that the host's /etc/resolv.conf is incorrect, you have two choices:

  1. The DNS server is hardcoded in daemon.json. This is simple, but not ideal if you anticipate the DNS server changing.

  2. Fix the hosts' /etc/resolv.conf file. This is a little more difficult, but it is generated dynamically, and the DNS server is not hardcoded.

answered Jan 3, 2023 by David
• 220 points

Related Questions In DevOps on Cloud

0 votes
1 answer

I am looking for a python code to get my Azure VM status in my email , like whether the running vms port is open to the internet. If its open to internet I should get a mail notification

Hey, @Sourav, Check this out https://www.edureka.co/community/66025/azure-vm-monitoring It deals with ...READ MORE

answered May 29, 2020 in DevOps on Cloud by Sirajul
• 59,230 points
1,802 views
+1 vote
0 answers
0 votes
0 answers

How do I change timezone in a docker container?

I'm running a docker container from docker-hub ...READ MORE

Jan 5, 2023 in DevOps on Cloud by Damonlang
• 1,230 points
790 views
0 votes
2 answers

Configure Subdomains, Nginx-proxy and Docker-compose

If you are already using docker-compose I ...READ MORE

answered Aug 3, 2018 in DevOps on Cloud by Nilesh
• 7,060 points
8,644 views
0 votes
1 answer
+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,020 points
2,714 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