Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Docker logs command

Docker logs command

Docker Command ReferenceDocker Command Reference


docker logs The command is used to get and view the log output of a container.

docker logs The command is very useful and can help users debug and monitor running containers.

Syntax

docker logs [OPTIONS] CONTAINER

Common options:

Example

Show container logs



docker logs my_container

Show all logs of the container named my_container, with the following output:

hello world

hello world

hello world

...

Follow log output



docker logs -f my_container

Continuously display the log output of my_container, with the following output:

hello world

hello world

hello world

...

Show logs with timestamps



docker logs -t my_container

Show logs that include timestamps, with the following output:

2023-07-22T15:04:05.123456789Z hello world

2023-07-22T15:04:06.123456789Z hello world

2023-07-22T15:04:07.123456789Z hello world

...

Show logs starting from a specified time





docker logs --since="2023-07-22T15:00:00" my_container

Show logs after 2023-07-22T15:00:00.

** Show the last 10 lines of logs**



docker logs --tail 10 my_container

Show the last 10 lines of logs for my_container.

** Show logs with extra detailed information**



docker logs --details my_container

Show the logs of my_container with extra detailed information included.

** Show logs up to a specified time**



docker logs --until="2023-07-22T16:00:00" my_container

Show logs before 2023-07-22T16:00:00.


Docker Command ReferenceDocker Command Reference