{"id":319,"date":"2019-10-24T11:27:00","date_gmt":"2019-10-24T03:27:00","guid":{"rendered":"http:\/\/www.luyouli.com\/?p=319"},"modified":"2019-10-24T11:29:30","modified_gmt":"2019-10-24T03:29:30","slug":"%e8%a7%a3%e5%86%b3docker-restart%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.luyouli.com\/?p=319","title":{"rendered":"\u89e3\u51b3docker restart\u7684\u95ee\u9898"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">1024\u7a0b\u5e8f\u733f\/\u7a0b\u5e8f\u5a9b\u8282\u65e5\u5feb\u4e50\uff0c\u66f4\u65b0\u4e2a\u6587\u7ae0\u5e86\u795d\u4e00\u4e0b\u8282\u65e5 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u8fd1\u673a\u5668\u5b66\u4e60\u7684docker\u603b\u662f\u56e0\u4e3a\u663e\u5b58\u4e0d\u8db3\u5bfc\u81f4\u5d29\u6e83\uff0c\u5d29\u6e83\u4e4b\u540e\u5c31\u65e0\u6cd5\u63d0\u4f9b\u670d\u52a1\uff0c\u9a8c\u770b\u4e86\u4e0b\uff0c\u6700\u7ec8\u53d1\u73b0\u5728\u542f\u52a8\u547d\u4ee4\u4e2d\u6ca1\u6709\u52a0\u5165&#8211;restart=always\u7684\u547d\u4ee4 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> \u539f\u547d\u4ee4\uff1a<\/p>\n\n\n<p><!--more--><\/p>\n\n\n<p class=\"wp-block-paragraph\">&#8216;nvidia-docker run {it} -p {port}:{in_port} -v {model_dir}\/:\/luyouli vision:{image} \/luyouli\/{date}\/config.yaml {v}&#8217; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> \u65b0\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8216;nvidia-docker run {it} &#8211;restart=always -p {port}:{in_port} -v {model_dir}\/:\/luyouli vision:{image} \/luyouli\/{date}\/config.yaml {v}&#8217; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> \u4f46\u662f\u5df2\u7ecf\u542f\u7528\u7684docker\u5c31\u4e0d\u80fd\u901a\u8fc7\u65b0\u5efa\u7684\u65b9\u6cd5\u89e3\u51b3\u4e86\uff0c\u9700\u8981\u66f4\u65b0\u914d\u7f6e<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># docker update &#8211;restart=always Container_ID<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># docker inspect Container_ID <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u627e\u5230RestartPolicy<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\"RestartPolicy\": { \n                 \"Name\": \"always\",                                             \n                 \"MaximumRetryCount\": 0  \n}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"273\" height=\"75\" src=\"https:\/\/www.luyouli.com\/wp-content\/uploads\/2019\/10\/1.png\" alt=\"\" class=\"wp-image-323\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6837\u5c31\u89e3\u51b3\u4e86\u91cd\u542fdocker-ce\u4e4b\u540e\u7684\u5bb9\u5668\u542f\u52a8\u95ee\u9898 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> \u968f\u4e4b\u800c\u6765\u7684\u662f\u53e6\u4e00\u4e2a\u95ee\u9898\uff0c\u6211\u8981\u5220\u9664\u4e00\u4e2a\u914d\u7f6e\u4e86restart=always\u7684\u5bb9\u5668\u7684\u8bdd\uff0c\u9700\u8981\u5148\u5220\u9664restart\u7684\u914d\u7f6e\uff0c\u5426\u5219\u8fd9\u4e2a\u5bb9\u5668\u4f1a\u4e00\u6b21\u4e00\u6b21\u53c8\u4e00\u6b21\u7684\u81ea\u52a8\u542f\u52a8\u542f\u52a8\u518d\u542f\u52a8 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># docker update &#8211;restart=no Container_ID <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u627e\u5230\u521a\u624d\u914d\u7f6e <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"272\" height=\"73\" src=\"https:\/\/www.luyouli.com\/wp-content\/uploads\/2019\/10\/2.png\" alt=\"\" class=\"wp-image-324\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6837\uff0c\u5c31\u89e3\u51b3\u4e86\u5bb9\u5668\u65e0\u6cd5\u5220\u9664\u7684\u95ee\u9898<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b98\u7f51\u5730\u5740\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/docs.docker.com\/engine\/reference\/run\/\">https:\/\/docs.docker.com\/engine\/reference\/run\/<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"restart-policies---restart\">Restart policies (&#8211;restart)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using the&nbsp;<code>--restart<\/code>&nbsp;flag on Docker run you can specify a restart policy for how a container should or should not be restarted on exit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a restart policy is active on a container, it will be shown as either&nbsp;<code>Up<\/code>&nbsp;or&nbsp;<code>Restarting<\/code>&nbsp;in&nbsp;<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/ps\/\"><code>docker ps<\/code><\/a>. It can also be useful to use&nbsp;<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/events\/\"><code>docker events<\/code><\/a>&nbsp;to see the restart policy in effect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker supports the following restart policies:<\/p>\n\n\n\n<table class=\"wp-block-table is-style-stripes\"><thead><tr><th>Policy<\/th><th>Result<\/th><\/tr><\/thead><tbody><tr><td><strong>no<\/strong><\/td><td>Do not automatically restart the container when it exits. This is the default.<\/td><\/tr><tr><td><strong>on-failure<\/strong>[:max-retries]<\/td><td>Restart only if the container exits with a non-zero exit status. Optionally, limit the number of restart retries the Docker daemon attempts.<\/td><\/tr><tr><td><strong>always<\/strong><\/td><td>Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container.<\/td><\/tr><tr><td><strong>unless-stopped<\/strong><\/td><td>Always restart the container regardless of the exit status, including on daemon startup, except if the container was put into a stopped state before the Docker daemon was stopped.<\/td><\/tr><\/tbody><\/table>\n","protected":false},"excerpt":{"rendered":"<p>1024\u7a0b\u5e8f\u733f\/\u7a0b\u5e8f\u5a9b\u8282\u65e5\u5feb\u4e50\uff0c\u66f4\u65b0\u4e2a\u6587\u7ae0\u5e86\u795d\u4e00\u4e0b\u8282\u65e5 \u6700\u8fd1\u673a\u5668\u5b66\u4e60\u7684docker\u603b\u662f\u56e0\u4e3a\u663e\u5b58\u4e0d\u8db3\u5bfc\u81f4\u5d29\u6e83\uff0c\u5d29 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-docker"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"views":7624,"_links":{"self":[{"href":"https:\/\/www.luyouli.com\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.luyouli.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.luyouli.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.luyouli.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.luyouli.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":9,"href":"https:\/\/www.luyouli.com\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":330,"href":"https:\/\/www.luyouli.com\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions\/330"}],"wp:attachment":[{"href":"https:\/\/www.luyouli.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.luyouli.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.luyouli.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}