I am Having Issues with Docker Container Networking on Ubuntu 20.04

Hello there,

I am currently running Ubuntu 20.04 with Docker containers; and I have been facing some issues related to container networking. My setup includes several containers for different services like a web server, database, and reverse proxy; and while they are running fine individually; I am having trouble getting them to communicate correctly across networks.

The main issue is that containers on different networks cannot ping each other, despite being on the same Docker host. I have tried using the default bridge network and also set up a custom network using the driver=bridge option, but the issue persists. I have also tried running docker network inspect and the results seem correct, with the containers attached to the right networks.

I have also made sure that the firewall on the host machine is not blocking the connections; but it does not seem to resolve the issue. I have found some posts mentioning that certain configurations in Docker might be causing these networking issues; such as conflicting IP ranges or problems with the Docker DNS server; but I have not been able to pinpoint the cause.

Has anyone here dealt with a similar issue or have suggestions on how I can troubleshoot further? Are there any settings or tools in Ubuntu or Docker that I might be overlooking that could fix the network connectivity problem between containers?

Thanks in advance for your help and assistance.

You say they are on different networks here, but then say you tried putting them on a custom bridge, is it the same custom bridge? If they are on different networks and you dont specifically allow internetwork communication (just like networks outside of docker) the traffic will be blocked.
You also haven’t provided enough info for us to assist. Pick two (of our) containers that cant ping each other, show us the docker compose or docker run, then show us how you’re trying (and failing) to ping.

Finally, ensure you’re not running the snap version of docker, as it just breaks everything.
snap list | grep docker
if this gives you something like
docker 20.10.24 2904 latest/stable canonical** -
you need to remove the snap version of docker and install docker ce, as per docker’s installation instructions.