docker logs

Fetch and stream logs from a Docker container.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

docker logs retrieves the stdout/stderr output of a container. The -f flag follows live output, --since filters by time, and --tail limits lines. For containers using json-file or local log drivers; doesn't work with syslog/journald drivers.

Common flags
FlagMeaning
-f --followStream logs in real time
--tailNumber of lines to show from end
--sinceShow logs since timestamp or duration
--timestampsShow timestamps
Examples
docker logs -f --tail 100 mycontainerFollow last 100 lines of container logs · explain & risk-check →
docker logs --since 30m mycontainerLogs from last 30 minutes · explain & risk-check →
docker logs --timestamps mycontainer 2>&1 | grep ERRORFilter errors with timestamps · explain & risk-check →
Pro tip

Use `docker logs --since $(date -d '1 hour ago' -u +%Y-%m-%dT%H:%M:%SZ)` to get exactly one hour of logs aligned to UTC — useful for incident correlation.

Related
docker ps journalctl tail
Open the full explainer →More in Docker & Containers

Reference text is hand-written and may be incomplete — check man docker for your version. Test destructive commands on a non-production system first.