{"id":14300,"date":"2023-08-02T14:53:18","date_gmt":"2023-08-02T06:53:18","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=14300"},"modified":"2026-01-27T10:16:58","modified_gmt":"2026-01-27T02:16:58","slug":"docker-11","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/08\/02\/docker-11\/","title":{"rendered":"Docker\u5e38\u89c1\u95ee\u9898\u6c47\u603b"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>1\u3001docker\u542f\u52a8\u62a5\u9519\uff0c\u9519\u8bef\u5185\u5bb9\u5982\u56fe<\/strong>\uff1a<\/mark><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"225\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/9.png\" alt=\"\" class=\"wp-image-14303\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/9.png 664w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/9-300x102.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/9-600x203.png 600w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\uff0c\u9519\u8bef\u7684\u5927\u81f4\u610f\u601d\u5c31\u662f\u6253\u5f00\u6587\u4ef6\u6570\u9650\u5236\u4f4f\u4e86<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u6211\u4eec\u67e5\u770b\u672c\u673a\u8bbe\u7f6e\u7684\u9488\u5bf9\u8fdb\u7a0b\u7ea7\u522b\u7684\u6253\u5f00\u6587\u4ef6\u6570\uff0c\u53ef\u901a\u8fc7ulimit -n \u6216\u8005\u67e5\u770blimit.conf\u6587\u4ef6\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"139\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/3-1.png\" alt=\"\" class=\"wp-image-14306\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/3-1.png 703w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/3-1-300x59.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/3-1-600x119.png 600w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u518d\u6765\u67e5\u770b\u4e0bdocker\u7684\u670d\u52a1\u6587\u4ef6\u4e2d\u662f\u5426\u914d\u7f6e\u4e86\u6253\u5f00\u6587\u4ef6\u9650\u5236\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"177\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/4.png\" alt=\"\" class=\"wp-image-14308\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/4.png 706w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/4-300x75.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/4-600x150.png 600w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u56fe\u770b\u51fa\uff0c\u670d\u52a1\u4e2d\u914d\u7f6e\u4e86LimitNOFILE=infinity\uff0cinfinity\u7684\u503c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e3a65536\uff0c\u8d85\u8fc7\u4e86\u8bbe\u7f6e\u7684\u8fdb\u7a0b\u7ea7\u522b\u7684\u53c2\u6570\u503c65535\uff0c\u56e0\u6b64\u542f\u52a8\u4f1a\u62a5\u9519\uff0c\u89e3\u51b3\u65b9\u6848\u662f\u4fee\u6539docker\u670d\u52a1\u4e2d\u7684\u8fd9\u4e2a\u53c2\u6570\u503c\uff0c\u5c06\u6253\u5f00\u6587\u4ef6\u6570\u4ee5\u53ca\u6253\u5f00\u8fdb\u7a0b\u6570\u90fd\u8bbe\u7f6e\u4e3a65535(limits.conf\u4e2d\u8bbe\u7f6e\u4e86\u8fdb\u7a0b\u6570\u6700\u5927\u4e5f\u662f65535,\u56e0\u6b64\u987a\u4fbf\u6539\u4e86\uff0c\u4ee5\u514d\u65e5\u540e\u51fa\u95ee\u9898)\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"141\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/6.png\" alt=\"\" class=\"wp-image-14318\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/6.png 703w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/6-300x60.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/08\/6-600x120.png 600w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539\u597d\u4e86\u540e\u53ef\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u91cd\u65b0\u52a0\u8f7d\u6587\u4ef6\u5e76\u91cd\u542f\u670d\u52a1\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl daemon-reload\nsystemctl restart docker<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff1a\u5982\u679c\u5728\u8fdb\u7a0b\u7684\u542f\u52a8\u670d\u52a1\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u4e86LimitNOFILE\u8fd9\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48\u53c2\u6570\u7684\u503c\u4e00\u5b9a\u8981\u5c0f\u4e8e\u5728limits.conf\u4e2d\u8bbe\u7f6e\u7684\u503c\uff0c\u5982\u679c\u5927\u4e8e\uff0c\u90a3\u4e48\u542f\u52a8\u5fc5\u7136\u62a5\u9519\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">2\u3001\u542f\u52a8\u5bb9\u5668\u63d0\u793a\u9519\u8bef\u5982\u4e0b\uff1a<\/mark><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused \"process_linux.go:449: container init caused \\\"write \/proc\/self\/attr\/keycreate: permission denied\\\"\": unknown<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\u65b9\u6848\uff1a\u5173\u95edslinux\u5373\u53ef<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e34\u65f6\u5173\u95ed\uff1asetenforce 0<\/li>\n\n\n\n<li>\u6c38\u4e45\u5173\u95ed\uff1avim \/etc\/selinux\/config\uff0c\u4fee\u6539enforcing\u4e3adisabled<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>3\u3001\u5bb9\u5668\u5185\u90e8\u65e0\u7f51\u7edc<\/strong>:<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u521b\u5efa\u5bb9\u5668\u540e\uff0c\u5bb9\u5668\u5185\u90e8\u65e0\u6cd5ping\u901a\u5916\u9762\u7684\u7f51\u7edc\uff0c\u6bd4\u5982ping www.baidu.com\u4e0d\u901a\uff0c\u4f46\u662fping\u7f51\u5173\u662f\u53ef\u4ee5\u7684\uff0c\u4e5f\u5c31\u662fdocker0\u5730\u5740\u662f\u901a\u7684\uff0c\u6b64\u65f6\u53ef\u53c2\u8003\u7684\u89e3\u51b3\u65b9\u6848\u4e3a\u76f4\u63a5\u4fee\u6539\u4e0bdocker0\u7684\u5730\u5740\uff0c\u7136\u540e\u91cd\u542fdocker\u5373\u53ef<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ed8\u8ba4\u60c5\u51b5\u4e0bdocker0\u7684IP\u5730\u5740\u4e3a172\u7f51\u6bb5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"694\" height=\"152\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/9-4.png\" alt=\"\" class=\"wp-image-15614\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/9-4.png 694w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/9-4-300x66.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/9-4-600x131.png 600w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539\/etc\/docker\/daemon.json\u6587\u4ef6\uff0c\u6dfb\u52a0bip\u5b57\u6bb5\u5373\u53ef\u4fee\u6539docker0\u5730\u5740\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"158\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/10-3.png\" alt=\"\" class=\"wp-image-15615\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/10-3.png 695w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/10-3-300x68.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/10-3-600x136.png 600w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539\u540e\u7684docker0\u5730\u5740\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"694\" height=\"204\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/11-1.png\" alt=\"\" class=\"wp-image-15616\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/11-1.png 694w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/11-1-300x88.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/11\/11-1-600x176.png 600w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">4\u3001\u5bb9\u5668\u5185\u914d\u7f6e\/etc\/hosts\u540e\u91cd\u542f\u5931\u6548<\/mark><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\u529e\u6cd5\uff1a\u5bb9\u5668\u5982\u679c\u662f\u901a\u8fc7&#8211;net=host\u7684\u4e3b\u673a\u6a21\u5f0f\u6765\u542f\u52a8\u7684\uff0c\u90a3\u4e48\u540c\u6b65\u7684\u662f\u4e3b\u673a\u7684hosts\u6587\u4ef6\uff0c\u56e0\u6b64\u5982\u679c\u60f3\u5728\u5bb9\u5668\u4e2d\u914d\u7f6e\/etc\/hosts\uff0c\u90a3\u4e48\u76f4\u63a5\u5728\u5bbf\u4e3b\u673a\u914d\u7f6e\/etc\/hosts\u5373\u53ef\uff0c\u5bb9\u5668\u542f\u52a8\u540e\u5373\u53ef\u540c\u6b65\u5230\u91cc\u9762<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">5\u3001\u5bb9\u5668\u8fd0\u884ccentos\u540e\uff0c\u5728\u5185\u90e8\u53ea\u80fdPing\u901aip\uff0c\u65e0\u6cd5ping\u901a\u57df\u540d\uff1f<\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>firewall-cmd --zone=public  --add-masquerade  --permanent #\u5141\u8bb8\u9632\u706b\u5899\u4f2a\u88c5IP\nfirewall-cmd --reload #\u91cd\u542f\u9632\u706b\u5899\u4f7f\u4e4b\u751f\u6548\nsystemctl restart docker #\u91cd\u542fdocker\u670d\u52a1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001Debian 13\u7248\u672c\u5b89\u88c5docker\u62a5\u9519\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ElectronicSeal dockerd&#91;3428]: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register \"bridge\" driver: failed to create NAT chain DOCKER: iptables not found<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u9519\u8bef\u8868\u660e Docker \u542f\u52a8\u65f6\u65e0\u6cd5\u627e\u5230 <code>iptables<\/code> \u547d\u4ee4\u3002\u4ece Debian 10 (Buster) \u5f00\u59cb\uff0c\u7cfb\u7edf\u9ed8\u8ba4\u4f7f\u7528 <code>nftables<\/code> \u66ff\u4ee3\u4e86 <code>iptables<\/code>\uff0c\u800c Docker \u4ecd\u7136\u4f9d\u8d56 <code>iptables<\/code>\uff0c\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u6cd5\u4e00\uff1a \u5b89\u88c5iptables<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install iptables<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u6cd5\u4e8c\uff1a \u914d\u7f6e Docker \u4f7f\u7528 nftables\uff08\u8f83\u65b0\u65b9\u5f0f\uff09\uff0c\u914d\u7f6e\/etc\/docker\/daemon.json\u6587\u4ef6\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\"iptables\": false\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001docker\u542f\u52a8\u62a5\u9519\uff0c\u9519\u8bef\u5185\u5bb9\u5982\u56fe\uff1a \u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\uff0c\u9519\u8bef\u7684\u5927\u81f4\u610f\u601d\u5c31\u662f\u6253\u5f00\u6587\u4ef6\u6570\u9650\u5236\u4f4f\u4e86 \u9996\u5148\u6211\u4eec\u67e5\u770b\u672c [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":14301,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-14300","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=14300"}],"version-history":[{"count":16,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14300\/revisions"}],"predecessor-version":[{"id":19543,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14300\/revisions\/19543"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/14301"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=14300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=14300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=14300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}