docker logs
Packages and runtimes
Usage
docker logs [-f] [--tail <n>] <container>Shows what the main process of the container wrote to stdout and stderr; an app that logs into a file inside the container shows nothing here, and the logs disappear with the container.
Common flags
| Flag | Meaning |
|---|---|
| -f | follow new output as it arrives |
| --tail <n> | only the last n lines |
| --since <time> | from a point in time, e.g. 15m or a timestamp |
| --until <time> | up to a point in time |
| -t | prefix every line with a timestamp |
Examples
docker logs -f --tail 100 webthe last hundred lines, then follow
docker logs --since 15m webwhat happened in the last fifteen minutes
docker logs -t webthe same output with timestamps in front
The question is always what goes where: inside this project, or on the whole machine.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does docker logs do?
Shows what the main process of the container wrote to stdout and stderr; an app that logs into a file inside the container shows nothing here, and the logs disappear with the container.
Q. How do I type it?
docker logs [-f] [--tail <n>] <container> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man docker. This command sits under Packages and runtimes.
Related commands
man page: man docker-logs