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

FlagDescription
-f, --followFollow log output
--tailNumber of lines to show from end
--sinceShow logs since timestamp or duration
-t, --timestampsShow timestamps

Tips & best practices

Related commands

View full Docker cheatsheet →