docker logs
[root@xxxx xxxx]# docker logs --help
Usage: docker logs [OPTIONS] CONTAINER
Fetch the logs of a container
Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
--tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
--until string Show logs before a timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
[root@xxxx xxxx]#
OPTIONS
常用
-f
:实时输出日志--since
:show logs since timestamp--tail
:显示最后几行日志,如--tail=200
(最后200行日志)--until
:show logs before a timestamp
通过时间筛选日志
docker logs --since "2024-04-29" --until "2024-04-30" [docker容器名或容器id]
since
和until
选项可分开使用
查看某个日期至今所有日志,并持续输出
docker logs -f --since "2024-04-30" [docker容器名称或容器id]
f
选项为实时输出