app can't reach the database. Its logs show it can't even resolve the name db — could not translate host name "db". But db is healthy and running right next to it, and you can confirm both are on the network. Even stranger: if you use db's IP address directly it works, but the name never resolves.
Figure out why name resolution fails between two running containers, and fix it so app can reach db by name.
app — myapp:latest, Up, 172.17.0.2.db — postgres:15-alpine, Up, healthy, 172.17.0.3, port 5432.--network.$ docker exec app getent hosts db
$ echo $?
2 # nothing resolved
$ docker inspect -f '{{json .NetworkSettings.Networks}}' app
{"bridge":{...}} # app is on "bridge"
$ docker inspect -f '{{json .NetworkSettings.Networks}}' db
{"bridge":{...}} # db is on "bridge" too — same default net, no DNS
You've solved it when:
bridge/etc/resolv.conf problem.
docker network create appnet then
docker network connect appnet app + ... db), after which
docker exec app getent hosts db resolves.
docker CLI only.docker exec app getent hosts db resolves db's IP (thebridge network behave differently from a networkdocker network create?
db's 172.17.0.x IP (which does work today) a--link do here, and why is it the deprecated answer?