DOCKER · Learning guideTheory · Labs · Knowledge checks
Chapter 07

Monitoring, security and maintenance

Observe containers

Inspect logs, health, resource usage and restart policy. A running process does not automatically mean the application is healthy.

docker stats --no-stream
docker ps -a
docker events --since 5m
Hands-on lab: Identify a stopped container and its exit code.

Harden workloads

Run as non-root where practical; use minimal trusted base images, explicit resource limits, read-only filesystems where possible, vulnerability scanning and least-privilege permissions.

docker run --rm --read-only --cap-drop ALL alpine id
Hands-on lab: Explain why mounting the Docker socket inside a container is sensitive.

Recovery and backups

Document rebuild procedures, store Dockerfiles and Compose files in Git, keep data backups separate from images and regularly test restores.

docker system df
docker image prune
Hands-on lab: Review what can be safely pruned on a training host.