A container has gone quiet or noisy and you need to know why, and docker logs gets you there without touching the container at all.
The command is read-only: it never restarts, stops or modifies anything. Allow about ten minutes for a first check. You need Docker CLI access to the daemon and a container name or ID. These examples use Docker 29.8.1 and the installed docker-ce-cli command. Docker documents docker logs as an alias for docker container logs; the short form is quicker to type, but use the longer spelling in shared scripts if that makes the target clearer.
Start with a listing rather than guessing an ID. This does not need root when your account can already use Docker:
$ docker ps --all --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}'
CONTAINER ID NAMES STATUS
8f31c2a4d9e1 web-example Up 12 minutes
2b7a91e0c6fd worker-example Exited (1) 4 minutes ago
web-example.--all. A stopped container can still hold useful output.docker logs nginx only works if a container actually called nginx exists.Checkpoint: pick the exact container whose output you intend to read. If the listing is empty, check that the Docker daemon is running and your account has access before you do anything else.
Fetch the complete retained stream with:
$ docker logs web-example
The default is --tail all, so a container with a large retained log can dump a lot of terminal text. Docker writes standard output and standard error together in the result. A quiet result is not proof the application did nothing: it may log elsewhere, have no output yet, or use a logging configuration that does not retain readable output.
For a quick last-lines check, set an explicit tail count:
$ docker logs --tail 80 web-example
This is usually the best first command when a service has been noisy. --tail 0 is also handy when you only want to open a follow connection without replaying old lines.
Use --timestamps to compare container output against a deployment, request or host event:
$ docker logs --timestamps --tail 20 web-example
2026-09-23T10:41:02.153847231Z listening on :8080
2026-09-23T10:41:09.008112447Z request completed status=200
The lines depend on the application. The timestamp is Docker's own recorded time for each entry, shown in UTC in these examples; do not expect the sample messages from every image. If your application already prints its own timestamps, keeping both can help while troubleshooting, as long as you know which one came from Docker.
To watch a running container, add --follow:
$ docker logs --follow --tail 50 web-example
2026-09-23T10:45:00.000000000Z health check passed
2026-09-23T10:45:05.000000000Z health check passed
The command prints the selected retained lines first, then waits for new ones. Press Ctrl-C to stop watching: that interrupts your local log command, not the container.
Combine timestamps and follow mode when timing matters more than the raw message:
$ docker logs --follow --timestamps --tail 20 web-example
Checkpoint: stop with Ctrl-C once you have captured the event. Leave several follow commands running in separate terminals and it gets easy to read the wrong service, or mistake a repeated health message for a new failure.
Use --since to start at a timestamp or relative age, and --until to stop at one:
$ docker logs --timestamps --since 30m --until 5m web-example
This asks for entries from roughly 30 minutes ago up to roughly 5 minutes ago. A relative value such as 42m suits a recent incident. An ISO 8601 timestamp is less ambiguous when comparing two machines:
$ docker logs --since '2026-09-23T10:30:00Z' --until '2026-09-23T10:40:00Z' web-example
Keep the quotes around timestamps in scripts, so shell metacharacters or future formatting changes cannot alter the arguments. The time filters limit what Docker returns; they never delete older log data.
Some logging drivers can attach extra attributes to records. Request them with --details:
$ docker logs --details --tail 40 web-example
If no extra attributes were ever provided, the output may look unchanged: the option cannot recover metadata that was never stored.
If Docker says it cannot find the container, rerun the listing and check spelling:
$ docker ps --all --filter name=web-example --format '{{.ID}} {{.Names}} {{.Status}}'
If access is denied, use the normal Docker administration process for this host. Adding your account to the Docker group grants broad control over the daemon, so treat that as a security decision rather than a convenient shortcut. Running with sudo may work on a host set up that way, but it is not needed just to read logs when your account already has Docker access.
If the application logs to files inside the container, or ships records to an external collector, docker logs may not show them at all. Check the image's logging configuration and the service's own destination. Once a container is removed, its local logs may no longer be available through this command.
Redirecting output to an existing path with > truncates that file before Docker even finishes writing. Use a new path, and check it before you replace anything:
$ docker logs --timestamps web-example > web-example-2026-09-23.log
$ test -s web-example-2026-09-23.log && echo 'log capture is non-empty'
log capture is non-empty
If the capture fails or is not what you wanted, remove only that new file:
$ rm web-example-2026-09-23.log
Warning: that deletion is irreversible. Keep the file if it might be needed for an incident record, and avoid storing sensitive log output anywhere shared. Docker log output can contain tokens, personal data or request bodies even when the application never meant to expose them.
Ctrl-C, container left running.