Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example of log operation in Docker

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the operation examples of logs in Docker. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Log of Docker engine

Docker engine logs are usually handed over to Upstart (Ubuntu 14.04) or systemd (CentOS 7, Ubuntu 16.04). The former is generally located under / var/log/upstart/docker.log, while the latter is generally read through jounarlctl-u docker. The locations of different systems are different, as follows:

2. Log of Docker container

The container's logs can be accessed through the docker logs command, and can be viewed in real time using docker logs-f, just like tail-f. If you use Docker Compose, you can view it through docker-compose logs.

If you delve into its log location, the logs of each container will be stored in / var/lib/docker/containers// by default in json-file format. However, it is not recommended to read directly here, because Docker provides a more perfect log collection method: Docker log collection driver.

3. Docker container log example: view the log after a specified time, and only show the last 100 lines: docker logs-f-t-- since= "2018-02-08"-- tail=100 CONTAINER_ID view the log of the last 30 minutes: docker logs-- since 30m CONTAINER_ID view the log after a certain time: docker logs-t-since= "2018-02-08" CONTAINER_ID on "Log Operation examples in Docker" this article ends here Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report