命令 docker-compose logs
描述 View output from containers 显示容器的日志
用法 1 logs [options] [SERVICE...]
选项 1 2 3 4 5 Options: --no-color Produce monochrome output. -f, --follow Follow log output. -t, --timestamps Show timestamps. --tail="all" Number of lines to show from the end of the logs for each container.
注意 无
示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 $ docker-compose logs nginx1 | 172.19.0.1 - - [30/Mar/2022:16:20:24 +0000] "GET / HTTP/1.1" 200 5 "-" "curl/7.29.0" "-" ... $ docker-compose logs --tail 1 Attaching to nginx1 nginx1 | 192.168.31.11 - - [30/Mar/2022:16:21:11 +0000] "GET / HTTP/1.1" 200 5 "-" "curl/7.68.0" "-" $ docker-compose exec demo sh / total 8 drwxr-xr-x 2 root root 4096 Nov 13 05:03 . drwxr-xr-x 1 root root 4096 Nov 13 05:03 .. lrwxrwxrwx 1 root root 11 Nov 13 05:03 access.log -> /dev/stdout lrwxrwxrwx 1 root root 11 Nov 13 05:03 error.log -> /dev/stderr