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 Analysis of docker Container signal usage

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

Share

Shulou(Shulou.com)05/31 Report--

Docker container signal use example analysis, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Container signal usage

Programs running in the container usually want to do some cleaning before the container exits. The more common way is to listen for a signal and delay closing the container.

Docker provides the following features:

╰─➤ docker stop-- helpUsage: docker stop [OPTIONS] CONTAINER [CONTAINER...] Stop one or more running containersOptions:-- help Print usage-t,-- time int Seconds to wait for stop before killing it (default 10)

Docker 1.13 and above can specify STOP_TIMEOUT and STOP_SIGNAL parameters directly when creating a container:

$docker run-help...--stop-signal string Signal to stop a container, SIGTERM by default (default "SIGTERM")-stop-timeout int Timeout (in seconds) to stop a container...

But... no, no, no.

Let's test one:

Package mainimport ("fmt"os"os/signal"syscall"time") func main () {fmt.Println ("signal test") go func () {for {c: = make (chan os.Signal, 1) signal.Notify (c, syscall.SIGTERM) s: =

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