In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about how to understand Docker logs. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.
Efficient monitoring and log management is very important to keep the production system running continuously and steadily and to troubleshoot problems.
In the micro-service architecture, logging and monitoring become more and more important because of the large number of containers and rapidly changing characteristics. Given the short and irregular lifecycle of containers, some containers may no longer exist when we need debug problems. Therefore, a centralized log management system is an indispensable part of the production environment.
We will discuss the various technologies and schemes available for monitoring containers, first introduce the logs subcommand that comes with Docker, then discuss logging driver of Docker, and then learn several log management schemes that have been widely used: ELK, Fluentd, and Graylog.
Docker logs
Let's first take a look at the logging feature of Docker in the default configuration.
For a running container, Docker sends logs to the container's standard output device (STDOUT) and standard error device (STDERR), STDOUT and STDERR are actually the console terminals of the container.
For example, run the httpd container with the following command:
Docker run-p 80:80 httpd
Because we do not use the-d parameter when starting the log, the httpd container starts in the foreground, and the log is printed directly in the current terminal window.
If you add the-d parameter to run the container later, we won't see the output log.
In this case, if you want to view the container log, there are two ways:
Attach to the container.
Use the docker logs command to view the log.
Let's first take a look at attach's method. Run the docker attach command.
Attach went to the httpd container, but there was no output, because there is currently no new log information.
To generate a new log, curl localhost can be executed at another command line terminal in host.
At this point, the attach terminal will print out the new log.
Attach's method is not very convenient in practice because:
You can only see the log after attach, but the previous log is not visible.
It is troublesome to exit the attach state (Ctrl+p and then Ctrl+q), accidentally killing the container (such as pressing Ctrl+C).
The recommended way to view container logs is to use the docker logs command.
Docker logs can print out the complete log since the container starts, and the-f parameter can continue to print out the newly generated log, which is the same as the Linux command tail-f.
After reading the above, do you have any further understanding of how to understand Docker logs? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.