Docker bridge networking does not work in Ubuntu 22.04

Host networking works:

    $ docker run -it --network=host busybox ping google.com
    PING google.com (142.250.181.238): 56 data bytes
    64 bytes from 142.250.181.238: seq=0 ttl=58 time=86.721 ms
    64 bytes from 142.250.181.238: seq=1 ttl=58 time=86.572 ms
    64 bytes from 142.250.181.238: seq=2 ttl=58 time=86.631 ms

But bridge networking does not work:

    $ docker run -it --network=bridge busybox ping google.com
    ping: bad address 'google.com'

This is the latest Docker version 24.0.2 installed using: “curl https://get.docker.com/ | sh”
This is a cloud server from IONOS (1 and 1) that I can re-image. It is running Ubuntu 22.04.2 LTS
The Linux kernel version is: 5.15.0-73-generic

I have already tried re-imaging Ubuntu 22.04.2 and re-installing Docker, but that did not help.

I have tried adding /etc/docker/daemon.json

    {
        "dns": ["212.227.123.16", "212.227.123.17", "8.8.8.8"],
        "debug": true,
        "default-address-pools": [{"base":"10.11.0.0/24","size":24}]
    }

I have edited and rebooted /usr/lib/systemd/network/80-container-host0.network:

    [Network]
    IPForward=kernel

    $ brctl show
    bridge name     bridge id               STP enabled     interfaces
    docker0         8000.02424eafcdbb       no

    $ docker network inspect bridge
    [
    {
        "Name": "bridge",
        "Id": "2fe2b9b8da6ec5ceea3b7b6ccd3bb513d3e72b181cb1fc1d784d769b1279637e",
        "Created": "2023-06-04T17:01:21.576943695Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.11.0.0/24",
                    "Gateway": "10.11.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "2b176dfcfac36986b642150fa445c172b21f945cc96051e3921ee28b4dc84bd7": {
                "Name": "beautiful_wescoff",
                "EndpointID": "56f288769b0be1f723fd25a3b11469c60552d6fe282b3e6d7ae7a3031a4fb81b",
                "MacAddress": "02:42:0a:0b:00:02",
                "IPv4Address": "10.11.0.2/24",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
    ]
1 Like

I have the exact same problem with a (IONOS) Linux VPS Contract.

Hi, I also have the same problem with an IONOS vps server, the host network is working fine, the bridge is not working. I tried to contact the Italy customer service they opened a ticket for me with a server operator, in my opinion not at all competent he didn’t even know what docker was, according to her it was not included in my subscription and the solution is to switch to a cloud server, but I see the problem there too. In my opinion it’s the firewall blocking something, also because from the vps I don’t know how to change the rules other than using their panel.

After several hours of discussion with IONOS, they found the problem on global ubuntu configuration, this problem is probably solved, if not please contact IONOS support

Hi, do I have to reinstall the vps or should it work without doing anything? I contacted the assistant the problem is finding a competent operator, the one I spoke to didn’t even know what docker was

I have a solution for you, the problem is netplan, ubuntu 22.04 use netplan to adress ip via DHCP. You need to modify the file /etc/netplan/50-cloud-init.yaml and add en in front of the * :

network:
    ethernets:
        all:
            dhcp4: true
            dhcp6: true
            match:
                name: 'en*'
    renderer: networkd
    version: 2

this will force netplan to use DHCP only on interface en* and the docker interface is docker0

next apply the configuration and restart network:

netplan apply
sudo systemctl restart systemd-networkd

#Docker need to be restarted to request a new ip
systemctl restart docker
3 Likes

Wow It works! Thank you very much, you were very kind. Thank you.

Thank you. It also fixed my problem. With all of the things I originally tried to get it working, I wanted to start from a clean install of 22.04, then I installed Docker, then made the suggested fix, and it works great. Thanks again

Thank you! Ionos support worth less than zero, you saved us.

Solution also worked for me. Thanks.

You saved me after 3 days and night troubleshooting this issue. Thank you very much. <3

OMG! It took me 4 nights to find the cause of this issue but without any result. I almost had to reinstall the OS until I found your solution. Thank you very much =]]]