{"id":1773,"date":"2022-10-08T04:15:59","date_gmt":"2022-10-07T20:15:59","guid":{"rendered":"http:\/\/www.tra56.com\/?p=1773"},"modified":"2022-10-08T17:33:32","modified_gmt":"2022-10-08T09:33:32","slug":"1773","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/1773.html","title":{"rendered":"\u91cd\u542f\u670d\u52a1\u5668\u540eDocker\u670d\u52a1\u53ca\u5bb9\u5668\u81ea\u52a8\u542f\u52a8\u8bbe\u7f6e"},"content":{"rendered":"

\u91cd\u542f\u670d\u52a1\u5668\u540e\uff0c\u6211\u4eec\u77e5\u9053\u5982\u4f55\u91cd\u542fdocker\u670d\u52a1\uff08\u5c06\u542f\u52a8\u547d\u4ee4\u52a0\u5165\u5230\/etc\/rc.d\/rc.local\u914d\u7f6e\u6587\u4ef6\u4e2d\uff09\uff0c\u4f46\u662fdocker\u5bb9\u5668\u786e\u6ca1\u6709\u81ea\u52a8\u542f\u52a8\uff0c\u8fd8\u9700\u8981\u6211\u4eec\u624b\u52a8\u53bb\u542f\u52a8\u5bb9\u5668\u3002\u5982\u4f55\u80fd\u505a\u5230\u91cd\u542fdocker\u670d\u52a1\u540e\uff0c\u80fd\u81ea\u52a8\u91cd\u542fdocker\u5bb9\u5668\u5462\u3002<\/p>\n

\u4e24\u6761\u4e3b\u8981\u7684\u547d\u4ee4:
systemctl enable docker.service
docker update \u2013restart=always [container_name]<\/p>\n

docker\u5bb9\u5668\u81ea\u52a8\u542f\u52a8\u8bbe\u7f6e<\/p>\n

\u5728\u8fd0\u884cdocker\u5bb9\u5668\u65f6\u53ef\u4ee5\u52a0\u5982\u4e0b\u53c2\u6570\u6765\u4fdd\u8bc1\u6bcf\u6b21docker\u670d\u52a1\u91cd\u542f\u540e\u5bb9\u5668\u4e5f\u81ea\u52a8\u91cd\u542f\uff1a<\/p>\n

docker run \u2013restart=always<\/p>\n

\u5982\u679c\u5df2\u7ecf\u542f\u52a8\u4e86\u5219\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n

docker update \u2013restart=always<\/container><\/p>\n

\u2013restart\u5177\u4f53\u53c2\u6570\u503c\u8be6\u7ec6\u4fe1\u606f\uff1a<\/p>\n

no \u2013 \u5bb9\u5668\u9000\u51fa\u65f6\uff0c\u4e0d\u91cd\u542f\u5bb9\u5668\uff1b<\/p>\n

on-failure \u2013 \u53ea\u6709\u5728\u975e0\u72b6\u6001\u9000\u51fa\u65f6\u624d\u4ece\u65b0\u542f\u52a8\u5bb9\u5668\uff1b<\/p>\n

always \u2013 \u65e0\u8bba\u9000\u51fa\u72b6\u6001\u662f\u5982\u4f55\uff0c\u90fd\u91cd\u542f\u5bb9\u5668\uff1b<\/p>\n

\u8fd8\u53ef\u4ee5\u5728\u4f7f\u7528on-failure\u7b56\u7565\u65f6\uff0c\u6307\u5b9aDocker\u5c06\u5c1d\u8bd5\u91cd\u65b0\u542f\u52a8\u5bb9\u5668\u7684\u6700\u5927\u6b21\u6570\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cDocker\u5c06\u5c1d\u8bd5\u6c38\u8fdc\u91cd\u65b0\u542f\u52a8\u5bb9\u5668\u3002<\/p>\n

docker run \u2013restart=on-failure:10<\/p>\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

\u91cd\u542f\u670d\u52a1\u5668\u540e\uff0c\u6211\u4eec\u77e5\u9053\u5982\u4f55\u91cd\u542fdocker\u670d\u52a1\uff08\u5c06\u542f\u52a8\u547d\u4ee4\u52a0\u5165\u5230\/etc\/rc.d\/rc.local\u914d\u7f6e\u6587\u4ef6\u4e2d […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-1773","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1773"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=1773"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1773\/revisions"}],"predecessor-version":[{"id":1774,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1773\/revisions\/1774"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=1773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=1773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=1773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}