格式:docker container logs [OPTIONS] CONTAINER
-t:日志显示加上时间戳
-f:为日志追踪模式等同于tailf效果
-t:日志显示加上时间戳
-f:为日志追踪模式等同于tailf效果
-t:日志显示加上时间戳;默认是不显示时间戳的
[root@localhost data]# docker container logs -t nginx 2019-01-31T03:17:44.319071309Z 192.168.80.1 - - [31/Jan/2019:03:17:44 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:17:44.798148003Z 192.168.80.1 - - [31/Jan/2019:03:17:44 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:17:45.088876036Z 192.168.80.1 - - [31/Jan/2019:03:17:45 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:17:45.266688588Z 192.168.80.1 - - [31/Jan/2019:03:17:45 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:17:45.449043348Z 192.168.80.1 - - [31/Jan/2019:03:17:45 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:33.915925608Z 192.168.80.1 - - [31/Jan/2019:03:21:33 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:34.491670969Z 192.168.80.1 - - [31/Jan/2019:03:21:34 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:34.843591995Z 192.168.80.1 - - [31/Jan/2019:03:21:34 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:35.020473695Z 192.168.80.1 - - [31/Jan/2019:03:21:35 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:35.207778164Z 192.168.80.1 - - [31/Jan/2019:03:21:35 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:35.389010463Z 192.168.80.1 - - [31/Jan/2019:03:21:35 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:35.562754644Z 192.168.80.1 - - [31/Jan/2019:03:21:35 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:35.734901477Z 192.168.80.1 - - [31/Jan/2019:03:21:35 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:35.916871057Z 192.168.80.1 - - [31/Jan/2019:03:21:35 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T03:21:36.107997109Z 192.168.80.1 - - [31/Jan/2019:03:21:36 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-"
-f:为日志追踪模式等同于tailf效果
[root@localhost data]# docker container logs -t -f nginx 2019-01-31T08:01:31.049662031Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.105231206Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.220514585Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.263025537Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.362787106Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.374828581Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.428257123Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.504792643Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.537910486Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.590458347Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-" 2019-01-31T08:01:31.681958283Z 192.168.80.1 - - [31/Jan/2019:08:01:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" "-"