Docker Environment Check
Validate Docker environment health before starting or debugging containerized services.
Steps
- Check Docker daemon:
docker info > /dev/null 2>&1— is Docker running?- If not running, report and suggest starting it
- Check Docker version:
docker --version
- List running containers:
docker ps --format "table \t\t"- Flag any containers in unhealthy or restarting state
- Flag any containers using ports needed by the current project
- Check port conflicts:
- Extract ports from
docker-compose.ymlorDockerfile - Check if those ports are already in use:
lsof -i :<port> - Report which process is using conflicting ports
- Extract ports from
- Validate Docker Compose (if applicable):
docker compose config --quiet— is the compose file valid?- Check that all referenced images exist or can be built
- Check that all referenced volumes and networks are defined
- Verify environment variables and
.envfile presence
- Check resource usage:
docker system df— disk usage by images, containers, volumes- Flag if disk usage is above 80%
- Suggest
docker system pruneif significant space can be reclaimed
- Check image freshness:
- List local images relevant to the project
- Flag images older than 30 days that might be stale
- Check if base images have security updates available
- Report summary:
- Docker status: running/stopped
- Containers: X running, Y stopped, Z unhealthy
- Port conflicts: list or “none”
- Disk usage: X GB used
- Recommendations: actions to take before starting services
Important
- Don’t start or stop containers automatically — report findings and let the user decide.
- Don’t expose secrets from container environment variables in the report.
- Check compose file format — v2 vs v3 syntax differences can cause subtle issues.