查询日志
docker compose logs -h
Flag shorthand -h has been deprecated, please use --help
Usage: docker compose logs [OPTIONS] [SERVICE...]
View output from containers
Options:
--dry-run Execute command in dry run mode
-f, --follow Follow log output.
--no-color Produce monochrome output.
--no-log-prefix Don't print prefix in logs.
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
-n, --tail string Number of lines to show from the end of the logs for each container. (default "all")
-t, --timestamps Show timestamps.
--until string Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
查询某个时间段的日志:
docker compose logs --since "2024-08-06T13:11:10" --until "2024-08-06T13:11:15" service-name
查询x分钟之前日志
docker compose logs --since 5m service-name
查询日志跟踪
docker compose logs -f service-name