How to view the last few lines of logs in docker

藏色散人
Release: 2021-12-13 13:56:03
Original
12315 people have browsed it

How to view the last few lines of docker logs: 1. Open the command window; 2. Dynamically view the last 100 lines of the log through the "docker logs -f -t --tail=100 c337e9df72a7" command.

How to view the last few lines of logs in docker

The operating environment of this article: ubuntu 18.04 system, Docker version 20.10.11, Dell G3 computer.

How to view the last few lines of logs in docker?

docker dynamically view the last 100 lines of the log:

docker logs -f -t --tail=100 c337e9df72a7
Copy after login

refers to the real-time view of the last 100 lines of the log with the container ID c337e9df72a7

How to view the last few lines of logs in docker

$ docker logs [OPTIONS] CONTAINER Options: --details 显示更多的信息 -f, --follow 跟踪实时日志 --since string 显示自某个timestamp之后的日志,或相对时间,如42m(即42分钟) --tail string 从日志末尾显示多少行日志, 默认是all -t, --timestamps 显示时间戳 --until string 显示自某个timestamp之前的日志,或相对时间,如42m(即42分钟)
Copy after login

Example:

View the log after the specified time, only display the last 100 lines:

$ docker logs -f -t --since="2018-02-08" --tail=100 CONTAINER_ID
Copy after login

View the log for the last 30 minutes:

$ docker logs --since 30m CONTAINER_ID
Copy after login

View logs after a certain time:

$ docker logs -t --since="2018-02-08T13:23:37" CONTAINER_ID
Copy after login

View logs during a certain time period:

$ docker logs -t --since="2018-02-08T13:23:37" --until "2018-02-09T12:23:37" CONTAINER_ID
Copy after login

Recommended learning: "Docker Video Tutorial"

The above is the detailed content of How to view the last few lines of logs in docker. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!