containers

docker logs

Fetches the stdout/stderr logs of a container. Works with the json-file and local logging drivers; other drivers require querying the destination directly.

docker logs [OPTIONS] CONTAINER

Common flags

Flag Purpose
-f, --follow Stream new log output as it arrives
--tail Show only the last N lines (or 'all')
--since Show logs since a timestamp or relative time (e.g., 10m)
--until Show logs before a timestamp
-t, --timestamps Prefix each line with a timestamp
-n Alias for --tail

Examples

docker logs -f web

Tail logs live like tail -f

docker logs --tail 100 --timestamps api

Last 100 lines with timestamps

docker logs --since 15m worker

Only entries from the last 15 minutes

docker logs api 2>&1 | grep ERROR

Combine stderr and stdout for grep

Gotcha

Docker logs only works with json-file/local drivers by default. When containers write to files inside themselves (e.g., /var/log/app.log) instead of stdout, docker logs shows nothing — log to stdout/stderr.

Related commands

← All Docker commands · Docker vs Kubernetes · Docker vs VMs