Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker networking only works with --net=host

Edit: I've managed to realize that the issue is with bridge networking, as network functionality seems fine with --net=host.

docker run -it --net=host busybox ping -c 1 8.8.8.8 works consistently.

Looking at this thread on reddit Docker network problem. Only works with --net=host the OP's issue was resolved by uninstalling ebtables. I've done the same but still have the same problem.

--

I've read through numerous threads (see below) trying to get to the bottom of an issue I'm having installing Discourse through a docker instance which fails when it tries to pull from github. Most threads point to issues in DNS, but I realized it's something else as I can't ping a static IP address either.

The discourse install fails with: cd /pups && git pull && /pups/bin/pups --stdin fatal: unable to access 'https://github.com/discourse/pups.git/': Could not resolve host: github.com

The oddest thing is that it works immediately after a restart:

systemctl restart docker

docker run -it busybox ping -c 1 8.8.8.8

PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 8.8.8.8: seq=0 ttl=58 time=0.646 ms

--- 8.8.8.8 ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 0.646/0.646/0.646 ms

docker run -it busybox ping -c 1 8.8.8.8

PING 8.8.8.8 (8.8.8.8): 56 data bytes

--- 8.8.8.8 ping statistics --- 1 packets transmitted, 0 packets received, 100% packet loss

No matter what, the subsequent call fails. I'm confused how to go about debugging this.

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic
Docker version 18.09.5, build e8ff056 (released 2019-04-11)

Attempted fixes:

  • Disabled UFW
  • https://meta.discourse.org/t/afatal-unable-to-access-https-github-com-samsaffron-pups-git-could-not-resolve-host-github-com/18611/7
  • https://stackoverflow.com/a/20431030/436014
  • https://stackoverflow.com/a/45644890/436014
like image 953
waffl Avatar asked Apr 18 '19 17:04

waffl


People also ask

Does Docker use host network?

In Docker, the host is a machine responsible for running one or more containers. Docker network host, also known as Docker host networking, is a networking mode in which a Docker container shares its network namespace with the host machine.

How does network work in Docker?

Docker includes support for networking containers through the use of network drivers. By default, Docker provides two network drivers for you, the bridge and the overlay drivers. You can also write a network driver plugin so that you can create your own drivers but that is an advanced task.

Can Docker containers access local network?

Your host can still be accessed from containers in the default bridge networking mode. You just need to reference it by its Docker network IP, instead of localhost or 127.0. 0.1 . Your host's Docker IP will be shown on the inet line.

What network interface does Docker use?

Bridge ModeBridge networking is the default Docker network type (i.e., docker0), where one end of a virtual network interface pair is connected between the bridge and the container.


1 Answers

Our IT department finally pinpointed this to some sort of issue with IPv6 in Ubuntu 18.x, somehow connected to this systemd issue udevd: Could not generate persistent MAC address for $name: No such file or directory #3374 and exists up to systemd version 247, for which there is no update for Ubuntu 18.x

In the end, updating the distribution to 20.x solved our issue.

like image 87
waffl Avatar answered Sep 20 '22 15:09

waffl