Docker Compose service discovery failure

The web service is unreachable from the Compose network.

Problem

The web service is unreachable from the Compose network.

Cause

Using the wrong service name or host port is a possible cause.

Solution

Check service health and logs. From a client on the same Compose network, use the service name and container port.

docker compose ps
docker compose logs web
docker compose run --rm client

View solution source on GitHub