Containers & Exec

How to View and Follow Docker Container Logs in Real Time

Inspect stdout and stderr output from containers with timestamps, tail line limits, and live streaming.

Quick Docker Solution
Safe CommandBeginner
docker logs -f --tail 100 <container-name>
When to use this scenario:Your container crashed or is behaving unexpectedly, and you need to monitor live incoming requests and stack traces.

Step-by-Step Execution Guide

1Stream live logs (Follow mode like tail -f)
docker logs -f <container-name>

Continuously outputs incoming log lines until you press Ctrl+C.

2View last 100 lines and stream
docker logs -f --tail 100 <container-name>

Prevents terminal buffer flooding by displaying only the latest 100 entries before tailing.

3Show timestamps with logs
docker logs -t --tail 50 <container-name>

Prepends each log line with an ISO 8601 UTC timestamp.

4View logs since a specific time
docker logs --since 30m <container-name>

Filters logs produced within the last 30 minutes (supports 10m, 2h, or ISO dates).

Critical Docker Pitfalls & Precautions

  • β€’Containers logging directly to internal files instead of stdout/stderr will not appear in "docker logs".
Frequently Asked Questions

View & Stream Container Logs - Frequently Asked Questions

Common questions about container isolation, signal handling, and runtime behavior.

By default, on Linux: /var/lib/docker/containers/<id>/<id>-json.log. Configure log rotation in daemon.json (max-size, max-file) to avoid filling disk.