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

How docker deploys springboot container logs

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "how docker deploys springboot container logs". In daily operation, I believe many people have doubts about how docker deploys springboot container logs. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how docker deploys springboot container logs". Next, please follow the editor to study!

After building the jdk and the required running jar into an image, and running it into a container, you can output the log in real time, but when the container dies, the log disappears. On the premise that the bash command can be run in the container, the container will generate the corresponding log file according to the log directory configured in jar. When the container is stopped, everything in the container will disappear, and you will encounter problems when querying the reason.

Method 1:

Docker logs containerId/containerName

The problem with this method is that it can only output the layer in real time, and the storage path is inside the container, and the log will disappear after the container is hung up. The problem with this method is that it can only output the layer in real time, and the storage path is inside the container, and the log will disappear after the container is hung up.

Method 2:

The manner of the data volume

Docker run-d-v / home/vincent/logs/:/logs/-p 8081 txxs/springboot

The first is the directory of the log in the host, and the back is the output directory of the log file in the container. The exposed port number is 8081.

In this way, the log can be seen on the host of the external docker, but the question is what to do when the mirror is started again. Instead of creating a new file, it is added directly at the end of the original file, that is, the log files of the two containers are merged into the same one. The method of change can be very simple, although the images are all the same, but the name of the log file can be generated dynamically, so that there is no problem above because the name of the log file is different when starting the image. The names of specific log files can be concatenated using time or IP+ serial numbers.

At this point, the study on "how docker deploys the springboot container log" 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!

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

Internet Technology

Wechat

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

12
Report