Pcornel
Containers · Docker & Compose Operations

Container Logs and Log Drivers

Cheat sheet · https://pcornel.dk/topic.php?topic=6138

Back to the Topic

Answer

Container logs are the process's stdout/stderr captured by the runtime via a log driver (json-file, journald, local, fluentd…) or, on Kubernetes, files on the node collected by a log agent.

Remember

Apps should log to stdout/stderr. Configure log rotation (max-size, max-file) or disks fill up. Kubernetes keeps only the current and previous container logs locally.

First checks

  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Commands

docker logs
kubectl logs

Verify in this order

stdout/stderr → log driver/node file → rotation → agent → central store

Where it usually breaks

Changing daemon.json does not affect existing containers.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6138

Confirmation

Confirm action

Continue?