brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: containers find each other by name on a custom Docker network, not on the default bridge

Docker
~/tips/tip-unraid-docker-network-names

docker network create mynet

Shows why a container name only works as a hostname on a user-defined Docker network.

When one container needs to talk to another, I would rather use a name than an IP address that can change.

That only works on a user-defined network. In the 6.5.1 announcement an Unraid developer explains it: on a user-defined bridge network containers can connect by DNS, with the container name as the hostname. Containers on the default bridge can reach the host and each other by internal IP address, but not by DNS.

Create the network once from the terminal:

docker network create mynet

Then put the containers that should find each other on that network. An app can then reach its database at the container name, for example postgres, and a changed IP address no longer matters.

The caveat is the docker.img file. A custom network is not kept when you delete it, so write down your networks with docker network ls first and recreate them with docker network create afterwards, as the Unraid docs advise.

Further reading: Unraid docs: Docker troubleshooting, On this site: Preserve user defined networks keeps your own Docker networks when Docker restarts, On this site: give Docker containers a wait time in the Unraid autostart column, On this site: Guide: put one Docker container on your tailnet with Unraid's built-in Tailscale option

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link