Back to questionsWhy does
JuniorTheoryVery common
Why does -h db resolve here, though it fails on the default bridge network?
docker network create shop
docker run -d --name db --network shop -e POSTGRES_PASSWORD=secret postgres:17
docker run --rm --network shop postgres:17 pg_isready -h dbOn a user-defined network such as shop, Docker's built-in DNS answers the name db with that container's IP. The default bridge network has no such DNS, so containers there reach each other only by IP.
- Expecting container names to resolve on the default bridge network
- Using the host's
localhostto reach another container instead of its name
- Which IP address answers DNS queries inside a container on a user network?
- How does Docker Compose give its services names without
docker network create?