如何检查Docker的重启策略是否有效 [英] How to check if the restart policy works of Docker

查看:61
本文介绍了如何检查Docker的重启策略是否有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Docker 文档中,有一个可以设置重启策略参数.

From the Docker document, there is a restart policy parameter could be set.

当容器退出时,如何验证容器确实重新启动.如何手动触发容器退出,并观察容器是否重新启动?

How do I verify the container indeed restarts when the container exits. How to trigger the exit of container manually, and observe if the container restarts?

我的环境是Mac和boot2docker.

My environment is Mac and boot2docker.

谢谢

推荐答案

,您还可以 docker exec -it container_id bash ,然后 kill -9 主进程.我用 docker run -d --restart = always -e DISPLAY = $ DISPLAY -v/home/gg/moncontainer:/home/gg -v/tmp/.X11-unix:/tmp/.X11-测试了Unix k3ck3c/captvty 我杀死了主进程(pid 5,Captvty.exe),从容器中注销,并在2秒后重新启动,再次创建了窗口

you can also docker exec -it container_id bash and then kill -9 of the main process. I tested with docker run -d --restart=always -e DISPLAY=$DISPLAY -v /home/gg/moncontainer:/home/gg -v /tmp/.X11-unix:/tmp/.X11-unix k3ck3c/captvty I killed the main process (pid 5, Captvty.exe), was logged out of the container, and 2 seconds later it was restarted, the window was created again

这篇关于如何检查Docker的重启策略是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆