Shared server guidance · Question & answer

How do I read recent Docker container logs without flooding the terminal?

docker logs reads output collected for the selected container’s standard output and standard error, subject to its logging driver. Limit both the time window and number of lines when investigating an incident. A container may also write separate application files that this command does not display.

BeginnerLinux servers using Docker Engine
Go to the answer

Before you start

  • Authorised Docker access and the exact container name.

Instructions

1. Confirm the container

Check its state and name before collecting logs. Similar application names can exist in development, staging and production contexts.

Remote Linux shell
docker ps --all --filter name=app

Lists matching containers; confirm the exact name before using it below.

2. Read a bounded time window

Replace app with the actual container name. Keep the time window close to the incident and redact sensitive values before sharing any extract.

Remote Linux shell
docker logs --since 15m --tail 100 --timestamps app

Returns up to the most recent hundred collected lines from the selected fifteen-minute window.

3. Follow a brief reproduction if needed

Follow only while reproducing an approved request, then press Ctrl+C. This stops the log client, not the running application container.

Remote Linux shell
docker logs --follow --since 2m --tail 20 app

Streams new collected output after a small initial extract.

Check the result

  • Relevant error entries align with the failing request time and the correct container instance.

Troubleshooting

No application errors appear
Check whether the application writes files or uses a remote logging driver, and whether the selected container was replaced after the incident.
Logs contain secrets or customer details
Share only a redacted minimal extract and correct the application’s logging practice through its owner.

Official references

Use the documentation for your installed version when a flag, service name or platform feature differs.