Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Urgent, need help!! My Docker Container can't access internet

So, simple:

  1. Create a new VM in GCe, choose ubuntu 20.04, and enable the ip_forwarding.
  2. SSH into it, and install docker. Following the official ubuntu installation guide https://docs.docker.com/engine/install/ubuntu 
  3. Then, because GCE VM uses dnsmasq, we need to add manual DNS, as mentioned in the troubleshooting https://docs.docker.com/engine/install/troubleshoot/#dns-resolver-issues
  4. Because GCE VM uses systemd-network, we need to add another entry, related to ip forwarding https://docs.docker.com/engine/install/troubleshoot/#ip-forwarding-problems 
  5. Restart the machine
  6. Run a simple image with network tools `docker run -it praqma/network-multitool bash`
  7. run `curl https://yahoo.com`
  8. run `ping yahoo.com`
  9. run `apk update`
  10. All failed! no Internet!

Why?? please help!

 

Update:

Turned out my shared_vpc is the culprit. When I deploy a VM into a default VPC, the docker container can work normally.

Update2:

The culprit is C3 machine type. If I use E2, then all work fine. Why???

TL;DR;

Docker container can't connect to internet on C3-type instance. But works on E2-type instance.

5 4 2,641