Configuring Docker network so that containers could access the Internet?

My problem is that even though I could connect to the container by using an address like [the host computer’s IP]:[the external port number I specified], the container itself cannot access to the Internet. I tried some things on the StackOverflow, but I could not get it work, and this is so complex that I do not know where to start. My setup is like below.


The host computer is connected to the router through an Ethernet adapter. I had created a bridge network bridge0 for QEMU/KVM, so my /etc/docker/daemon.json is like this.

{
    "bridge":"bridge0"
}

Now, if I create a container without specifying the networking, it seems that docker creates a bridge network named [container name]_default, whose IP address is something like 172.20.0.0 (The host’s network is 192.168.0.XX). The network details says that driver=bridge, scope=local, attachable=false, internal=false, IP4 subnet - 172.20.0.0/16, IP4 gateway - 172.20.0.1.

In the host computer’s network connections GUI, I see a bridge entry for that docker network. Its name is like “br-[start of the Docker network’s ID]”. Its Bridge tab is empty. Its IPv4 settings tab shows one address, and the DNS servers is empty. I tried adding an “Ethernet” entry to the Bridge tab, but that did not solve the problem.

Usually, that’s no problem and it works right away. Do you have a firewall that is not compatible with docker?
What exactly doesn’t work? Do you need a proxy?
What is your DNS?

No, no firewall, since Manjaro does not come with firewall enabled by default. I tried docker on a Windows computer which is connected to the same router, and yes, the container could access the internet (I tested it by issuing “apt update”) out-of-the-box. The Windows PC also has bridge enabled for virtual machines.

“What exactly doesn’t work” I don’t know. The container just cannot connect to the Internet. My DNS is my router, the 192.168.1.1 thing. Since this problem does not happen with the docker on the Windows PC which is connected to the same router, it probably isn’t a problem of the router’s DNS.

So anyway, let me be clear, on your Manjaro computer, which has one single Ethernet port and which has bridge network, containers can access Internet out-of-the-box?

I did some experiment. In short, it seems that container network access does not work after adding a bridge.

I installed latest Manjaro in a virtual machine that uses bridge network. I updated everything. Then, I installed Docker. I did not edit any Docker settings. Docker automatically created a bridge network named “docker0”. Then I executed docker run -it ubuntu bash. I typed apt update and it could connect to the Internet.

Now, I manually created a bridge network to replicate my server’s configuration, which has a manually-created bridge for QEMU/KVM. I then added an Ethernet to it, and deleted existing “Wired network”. I deleted the “docker0”, and created /etc/docker/daemon.json and added { "bridge":"bridge0" }, and rebooted. I deleted existing Docker containers and executed docker run -it ubuntu bash. Now I typed apt update and it failed to connect to the Internet. Of course, the virtual machine can access the Internet. My situation is summarised in the screenshot below.