Docker命令-logs

命令

docker logs

描述

Fetch the logs of a container
获取容器的日志

用法

1
docker logs [OPTIONS] CONTAINER

选项

1
2
3
4
5
6
7
Options:
--details Show extra details provided to logs
--follow , -f Follow log output
--since Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
--tail , -n Number of lines to show from the end of the logs,default is all
--timestamps , -t Show timestamps
--until Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)

注意

示例

1
2
3
4
5
6
# 查看实时日志
$ docker logs -f

$ docker run --name test -d busybox sh -c "while true; do $(echo date); sleep 1; done"
$ date
$ docker logs -f --until=2s test