Docker Compose Service Troubleshooting Guide
- 1 Purpose
- 2 1. Preliminary Checks
- 2.1 Recommended Actions
- 2.2 Avoid
- 3 2. Service Restart and Rebuild
- 3.1 Recommended Actions
- 3.2 Avoid
- 4 3. Container Health Verification
- 4.1 Recommended Actions
- 4.2 Avoid
- 5 4. Network and Proxy Troubleshooting
- 5.1 Recommended Actions
- 5.2 Avoid
- 6 5. Debugging Techniques
- 7 6. Best Practices Summary
- 8 7. Notes on Proxy Configuration
Purpose
This guide provides a structured approach to troubleshooting services running in Docker Compose, including networked services behind reverse proxies. It covers best practices, common pitfalls, and step-by-step diagnostics.
1. Preliminary Checks
Recommended Actions
Verify Docker and Docker Compose installation:
docker --versiondocker-compose --versionCheck the status of all containers:
docker-compose ps
Review container logs for errors or warnings:
docker-compose logsdocker-compose logs <service_name>Avoid
Modifying running containers without understanding service dependencies.
Making ad-hoc changes outside of version-controlled configuration files.
2. Service Restart and Rebuild
Recommended Actions
Restart a specific service:
docker-compose restart <service_name>Rebuild a service if the container appears corrupted or outdated:
docker-compose up -d --buildAvoid
Restarting all services simultaneously without assessing potential downtime.
Manually killing containers without using Docker Compose commands.
3. Container Health Verification
Recommended Actions
Inspect logs and health status of containers:
docker logs <container_id>docker inspect --format='{{.State.Health.Status}}' <container_id>Use healthchecks defined in to validate service readiness.
Avoid
Assuming that “running” containers are healthy; the application may still fail internally.
4. Network and Proxy Troubleshooting
Recommended Actions
Verify the proxy container is operational:
docker-compose psInspect proxy logs for connectivity or configuration errors:
docker-compose logs <proxy_service>Validate internal service reachability from the proxy container:
docker exec -it <proxy_container> curl http://<service_name>:<port>Ensure proper port mapping in :
ports:
"80:80"
"443:443"
Confirm Docker network connectivity:
docker network lsdocker network inspect <network_name>Avoid
Editing proxy configurations directly inside running containers.
Ignoring DNS resolution issues within the Docker network.
Exposing ports unnecessarily or misconfigured firewall rules.
5. Debugging Techniques
Access running containers for interactive troubleshooting:
docker-compose exec <service_name> /bin/shor
docker-compose exec <service_name> /bin/bashTest service endpoints internally:
curl http://localhost:<service_port>
Validate Docker Compose configuration:
docker-compose configUse structured logs and monitoring tools for more complex multi-container environments.
6. Best Practices Summary
Recommended | To Avoid |
Check logs before acting | Blindly restart all services |
Restart services individually | Edit live containers directly |
Verify health checks | Assume running = healthy |
Test proxy and network connectivity | Ignore DNS or network issues |
Debug with docker-compose exec | Patch container files manually |
7. Notes on Proxy Configuration
When troubleshooting a reverse proxy (Nginx, Traefik, Caddy, etc.):
Ensure the proxy configuration matches the internal service names and ports.
Validate SSL/TLS certificates and automatic renewals if applicable.
Reload or restart the proxy container after configuration changes:
docker-compose restart <proxy_service>Consider enabling verbose logging temporarily for advanced debugging.