docker logs Explained
What docker logs does, with an example.
Published November 8, 2026
docker logs prints the output (stdout and stderr) of a container. Use -f to follow it and --tail to limit lines.
How it works
Docker captures what the main process writes to stdout/stderr. Apps that write to files will show nothing here.
Log drivers can be configured for rotation and shipping.
Try it
docker logs -f --tail 20 web
10.0.0.1 - GET /index.html 200
10.0.0.2 - GET /missing 404
Practical examples
Follow
docker logs -f webLast 50 lines with timestamps
docker logs --tail 50 -t webSince a time
docker logs --since 10m webCompose services
docker compose logs -f app dbCommon mistakes
- Apps logging to files instead of stdout.
- Unbounded log files filling the disk.
- Not checking logs of crashed containers (docker logs still works).
Key takeaways
- docker logs prints the output (stdout and stderr) of a container.
- Run docker <command> --help for all options.
- Clean up unused resources regularly.
FAQ
Rotate logs?
Set max-size and max-file in the logging options.
Where can I see all options?
Run the command with --help.