🐥

【Docker】Does your docker can't connect to the internet?

に公開

1. An issue

The Docker container can't connect to the internet and doesn't improve by restarting the container.

2. Solution

2.1 Check the internet connection
curl -I www.google.com

・No Connection
curl: (6) Could not resolve host: www.google.com
・Successful Connection
HTTP/1.1 200 OK ...

2.2 Check the resolv.conf

This file was generated by Docker Engine.

cat /etc/resolv.conf

Overwrite this:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
echo "nameserver 1.1.1.1" | sudo tee -a /etc/resolv.conf

I solved this problem in this way.
please check again.

curl -I www.google.com

Discussion