docker logs
Fetch logs from a container. Shows stdout and stderr output.
Syntax
docker logs [OPTIONS] CONTAINER
Examples
Example 1
docker logs my-container
Show all logs from the container.
Example 2
docker logs -f --tail 100 my-container
Follow logs, show last 100 lines.
Example 3
docker logs --since 1h my-container
Show logs from the last hour.
Common flags
| Flag | Description |
|---|---|
| -f, --follow | Follow log output |
| --tail | Number of lines to show from end |
| --since | Show logs since timestamp or duration |
| -t, --timestamps | Show timestamps |
Tips & best practices
- •Use -f for real-time debugging (like tail -f).
- •Logs are stored in the container's JSON log file.