View a container's logs
Read-only
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Shows the recent log output of a container and then follows new lines live, without changing the container or its logging configuration.
dockerlogsdebug
Parameters
Container name or ID whose logs to read.
Number of most recent log lines to show initially.
Commands
Show the most recent log lines with timestamps
docker logs --tail 100 --timestamps <container>Stream new log lines live until interrupted with Ctrl+C
docker logs --follow --tail 0 <container>Verification
docker logs --tail 5 <container>Recent log lines are printed; empty output means the process wrote nothing to stdout or stderr.
Undo
Not undoable
This recipe only reads log output and changes nothing.
Pitfalls
- Only output written to stdout/stderr is captured; applications logging to files inside the container show nothing here.
- Logs of a removed container are gone; docker logs works for stopped but not deleted containers.
- With a non-default logging driver (for example syslog), docker logs may be unavailable.