Guide Docker Beginner

11. Logs, Health, and Resources

Inspect an application's process, logs, and resource use.

1 min read

Start with Evidence

For the container you are investigating, replace CONTAINER_NAME with its name:

docker ps -a
docker logs --tail 100 CONTAINER_NAME
docker inspect CONTAINER_NAME
docker stats --no-stream CONTAINER_NAME
docker top CONTAINER_NAME

Logs show application output written to stdout and stderr. Inspect shows configuration and state. Stats provides a point-in-time view of resource use.

Running vs Healthy

Running means the main process is alive. A health check tests a command that represents application health. An unhealthy status alone does not cause standalone Docker to restart the container automatically.

A restart policy responds to container exits according to its policy. It is not a replacement for fixing configuration errors or implementing readiness.

Resource Limits

docker run --rm --memory 64m --cpus 0.5 busybox:1.37 echo "resource-limited example"

The command demonstrates limit syntax; its small workload does not stress the limits. Size real limits using observed application behavior.

Practice

Compare the evidence needed for a stopped container, a running but unreachable server, and a memory-constrained application.

Quick Interview Answer

Diagnose state, logs, configuration, and resources together. Running, healthy, and reachable describe different properties.


Previous: 10. Docker Compose | Next: 12. Security and Best Practices

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form