Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the command for docker to view the container log

Shulou Source: shulou.com Published: 2022-06-01 11:24:47 10月29日 Update

This article mainly introduces "what is the command for docker to view the container log". In the daily operation, I believe that many people have doubts about the command of docker to view the container log. The editor has consulted all kinds of information and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "what is the command of docker to view the container log?" Next, please follow the editor to study!

You can view the container's log through the docker logs command.

Command format:

$docker logs [OPTIONS] CONTAINEROptions:--details displays more information-- f,-- follow tracks real-time logs-- since string displays logs since a certain timestamp, or relative time, such as 42m (that is, 42 minutes)-- how many lines of logs are displayed by tail string from the end of the log, default is all-t,-- timestamps displays timestamps-- until string displays logs before a certain timestamp, or relative time, such as 42m (that is, 42 minutes)

For example

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

$docker logs-f-t-since= "2019-08-08"-tail=100 CONTAINER_ID

View the log for the last 30 minutes:

$docker logs-- since 30m CONTAINER_ID

Using tail to view the tail of log, the effect is the same as Linux's tail-n20filename, showing the last 20 lines.

$docker logs-- tail 20

At this point, the study on "what is the command for docker to view container logs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Logs commands containers time learning more help practical and then for example information content real-time tail effects articles methods endings formats theory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS MariaDB Shulou Technology Redmi