← 返回命令列表

Linux command

docker-logs 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show container logs

docker logs [container]

Follow log output

docker logs -f [container]

Show last N lines

docker logs --tail [100] [container]

Show timestamps

docker logs -t [container]

Show logs since time

docker logs --since [2h] [container]

Show logs until time

docker logs --until [1h] [container]

说明

docker logs fetches the logs of a container. Shows STDOUT and STDERR output from the container's main process. Logs are captured by Docker's logging driver and can be filtered by time range or number of lines. Essential for debugging containerized applications and monitoring runtime behavior.

参数

-f, --follow
Follow log output.
--tail _string_
Number of lines from end (default "all").
-t, --timestamps
Show timestamps.
--since _string_
Show logs since timestamp or duration.
--until _string_
Show logs before timestamp or duration.
--details
Show extra details.

FAQ

What is the docker-logs command used for?

docker logs fetches the logs of a container. Shows STDOUT and STDERR output from the container's main process. Logs are captured by Docker's logging driver and can be filtered by time range or number of lines. Essential for debugging containerized applications and monitoring runtime behavior.

How do I run a basic docker-logs example?

Run `docker logs [container]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --follow do in docker-logs?

Follow log output.