46 / 55 · 19 Linux & Command Line · Docker Basics for QA← prev⊞ allnext →☰ Read as one page
6.6Docker Troubleshooting for QA
Common Issues
| Issue | Diagnosis | Fix |
|---|---|---|
| Container won't start | docker logs <container> |
Check error messages in logs |
| Port already in use | lsof -i :<port> |
Stop conflicting process or use different port |
| Container runs but app doesn't connect | docker network inspect |
Ensure containers are on the same network |
| "No space left on device" | docker system df |
Run docker system prune to clean up |
| Tests fail with connection refused | Check depends_on and healthchecks |
Add healthcheck; wait for service readiness |
Cleanup Commands
# Show disk usage by Docker
docker system df
# Remove all unused data (stopped containers, dangling images, unused networks)
docker system prune
# Remove all unused data including unused images (more aggressive)
docker system prune -a
# Remove specific types
docker container prune # Stopped containers
docker image prune # Dangling images
docker volume prune # Unused volumes
docker network prune # Unused networks