Skip to content

Fix Networking issues with Docker and KVM QEMU on Ubuntu

When using Docker in combination with QEMU, KVM, or some other hypervisor, and you have a network interface bridge set up (through netplan or brctl) or your host has to route packets through other means, you will encounter issues where once Docker is installed and running, the routing of packets stops and your other virtual machines lose all networking capabilities.

The official Docker documentation has actually a section about this scenario but you would have to be hitting the nail on the head with your search engine terms to find that gem.

This post from the Home Assistant forum also covers this issue and offers two solutions:

Solution 1: Accept packets on your bridge interface

This solution is also the one laid out on the Docker documentation and is the one that worked for me with my setup of Docker and QEMU (with libvirt).

Override the Docker systemd service by running:

sudo systemctl edit docker.service

Paste the following at the top of the file. Make sure to adjust the 'br0' with your bridge name.

ExecStartPost=/usr/sbin/iptables -I DOCKER-USER -i br0 -o br0 -j ACCEPT

Save the file. Then reload systemd and restart docker.

sudo systemctl daemon-reload
sudo systemctl restart docker

That should (hopefully) get it working again, if not, try solution #2.

Solution 2: Tell Docker about the network interface bridge

This solution didn't work on my main server, but worked on some other machine where I had LXD installed.

You can specify the bridge that Docker Daemon will use through the /etc/docker/daemon.json file.

Edit /etc/docker/daemon.json with the following:

  "bridge": "br0"

Then restart docker.

sudo systemctl restart docker