Skip to content

Troubleshoot Docker Compose Networking and DNS

Admin
November 18, 2026
5 min read
Intermediate
💻 Target OS: Ubuntu 24.04+ / Debian 12+ / RHEL 9+

Before you begin

  • Applies to:Docker Engine on Linux with Compose v2 and bridge networks.
  • Where to start:Open a terminal in the deployed Compose project on the Docker host. Use the same Docker context and project as the deployment.
  • What you need:Identify the source and destination services. The examples use web and api. The source needs getent and curl, and the destination needs ss. Use approved diagnostic tooling if these are missing. Keep the same shell for commands that share variables.
Guide tools
Guide tools
0/0 Steps (0%)

Use this guide when a service name does not resolve or a container cannot connect to another container. Check from the failing container because host DNS and host port checks exercise a different path.

Troubleshooting Steps

01

Check the project and shared network

Docker host

Run in the deployed project directory. Confirm the containers are running and inspect the actual memberships. Replace the example names with those from compose ps. The containers need a common network for the direct service-name path in this guide.

Terminal window
docker compose ps --all
docker compose config --services
docker inspect --type container --format '{{json .NetworkSettings.Networks}}' example-web-1 example-api-1
02

Resolve the service name and test HTTP

Source container

Run each command from the Docker host. Compose exec runs the probe inside web. The first command should return the service address. The second should return the expected status for the API health endpoint. A name failure points to network membership or service aliases. A refusal after resolution points toward the API listener or port.

What you should see · The source container resolves the API service name and the health endpoint returns its expected HTTP status.

If you see something else · If the name does not resolve, return to Step 1 and check the shared network and service name. If it resolves but the connection fails, go to Step 3 for the listener and container port. If HTTP responds with an error, inspect the API logs and health endpoint.

Terminal window
docker compose exec -T web getent hosts api
docker compose exec -T web curl --connect-timeout 3 --max-time 8 --fail --show-error http://api:8080/health
03

Check the service listener and host mapping

Destination container

For traffic from another container, confirm the application listens on a reachable container interface at 8080. An application bound to 127.0.0.1 inside the API container is reachable only from that container. The second command checks for a published host port. No published mapping is normal for an internal API.

Terminal window
docker compose exec -T api ss -lnt
docker compose port api 8080
04

Restore the intended path and verify

Resolution

Correct the identified service name, shared network, or application bind setting in version-controlled configuration. Use docker compose config —quiet to validate the edit. Apply it with the project’s deployment process, then repeat the source-container checks. For persistent failure restore the previous configuration and compare both containers’ memberships again.

Terminal window
docker compose config --quiet
docker compose exec -T web getent hosts api
docker compose exec -T web curl --connect-timeout 3 --max-time 8 --fail --show-error http://api:8080/health

References

Comments