✦ For everyone, free.

Practical knowledge for real and everyday life

Home

9.4.4.4 Exec Service Debugging

A focused guide to Exec Service Debugging, connecting core concepts with practical Docker and container operations.

Exec service debugging uses docker compose exec to directly investigate a running service's actual internal state — its environment variables, running processes, network connectivity, filesystem contents — when troubleshooting unexpected behavior or trying to understand why something isn't working as expected.

Checking the Service's Actual Environment

Confirming what environment variables a running container actually has, as opposed to what was intended, can reveal a configuration mismatch.

docker compose exec api env
Verifying Network Connectivity to a Dependency

Testing whether a service can actually reach another service it depends on helps isolate whether a problem is networking-related.

docker compose exec api ping db
docker compose exec api curl -v http://cache:6379
Inspecting Running Processes Inside the Container

Checking what processes are actually running inside a container can reveal whether an expected process has crashed or isn't running as intended.

docker compose exec api ps aux
Checking Filesystem State for Expected Files or Mounts

Confirming whether expected files, configuration, or mounted volumes are actually present and correctly populated rules out (or confirms) certain categories of misconfiguration.

docker compose exec api ls -la /app/config
docker compose exec api cat /app/config/settings.yaml
Combining Several Checks Into a Coherent Investigation

A real debugging session often combines several of these checks together, narrowing down a problem step by step.

docker compose exec api env | grep DATABASE
docker compose exec api ping db
docker compose exec db pg_isready
Why Exec Service Debugging Matters

This direct, exploratory access into a running service's actual state is often the most effective way to diagnose unexpected behavior, providing ground truth about a container's actual condition rather than relying solely on assumptions about what its configuration should produce.