LinuxCommandLibrary

docker-container-logs

view logs from a container

TLDR

View container logs

$ docker container logs [container]
copy
Follow log output
$ docker container logs -f [container]
copy
Show timestamps
$ docker container logs -t [container]
copy
Show last n lines
$ docker container logs --tail [100] [container]
copy
Logs since time
$ docker container logs --since [1h] [container]
copy

SYNOPSIS

docker container logs [options] container

DESCRIPTION

docker container logs fetches logs from a container's main process, displaying both standard output and standard error streams. This command is essential for debugging and monitoring containerized applications, allowing you to view historical logs or follow them in real-time.
Logs are collected from the container's configured logging driver, which by default captures stdout and stderr from the container's PID 1 process. Time-based filtering and tail options make it efficient to work with large log volumes.

PARAMETERS

-f, --follow

Follow log output.
-t, --timestamps
Show timestamps.
--tail n
Number of lines from end.
--since time
Show logs since timestamp.
--until time
Show logs before timestamp.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community