Read Docker container logs
Updated August 29, 2026
Use docker logs to read a container's stdout and stderr:
docker logs --tail 100 -f my-container
--tail 100 limits the initial output and -f follows new lines. Add --timestamps when correlating events. For a Compose service, use docker compose logs --tail 100 -f service-name.
This works when the application writes logs to its standard streams and the configured logging driver supports retrieval. It does not necessarily show files written inside the container. Inspect the driver with docker inspect --format '{{.HostConfig.LogConfig.Type}}' my-container and check Docker's logging-driver documentation before clearing files. Manually deleting Docker's internal log file can corrupt logging behavior and does not fix an application that emits too much output.
For production, choose rotation/retention settings, structured messages, and a central log destination deliberately. Never include tokens or personal data in logs just because docker logs is convenient.
Sources
related.
Ruslan Osipov
About the author