{"id":15513,"date":"2024-11-18T19:58:54","date_gmt":"2024-11-18T11:58:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=15513"},"modified":"2024-11-18T19:58:54","modified_gmt":"2024-11-18T11:58:54","slug":"docker%e7%9a%84%e5%90%af%e5%8a%a8%e5%8f%82%e6%95%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/15513\/","title":{"rendered":"Docker\u7684\u542f\u52a8\u53c2\u6570"},"content":{"rendered":"<p>\u542f\u52a8\u7684docker\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u662fdockerd\uff0c\u9996\u5148\u9700\u8981\u77e5\u9053 dockerd \u7684\u6587\u4ef6\u8def\u5f84\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528<br \/>\n&lt;path&gt;\/dockerd &amp; \u542f\u52a8docker\uff0c\u8fd9\u91cc\u8be6\u7ec6\u4ecb\u7ecd\u4e0b\u542f\u52a8\u53c2\u6570\u7684\u4f7f\u7528\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Tips 1\uff1a<\/strong>Docker\u4e2d\u7684\u7ec4\u4ef6\u4ecb\u7ecd<\/p>\n<p><strong>Tips 2\uff1a<\/strong>Docker\u7684\u914d\u7f6e\u6587\u4ef6 daemon.json \u8be6\u7ec6\u89e3<\/p>\n<p><strong>Tips 3\uff1a<\/strong>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u914d\u7f6e\u6587\u4ef6 deamon.json \u4e2d\u914d\u7f6e\u9879\u76ee\uff0c\u5728\u542f\u52a8\u53c2\u6570\u4e2d\u540c\u6837\u9002\u7528\uff08\u4f1a\u6709\u4e9b\u8bb8\u4e0d\u540c\uff09\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u7684\u4e00\u70b9\uff0c\u914d\u7f6e\u6587\u4ef6\u4e2d\u5982\u679c\u5df2\u7ecf\u6709\u67d0\u4e2a\u914d\u7f6e\u9879\uff0c\u5219\u65e0\u6cd5\u5728\u542f\u52a8\u53c2\u6570\u4e2d\u589e\u52a0\uff0c\u4f1a\u51fa\u73b0\u51b2\u7a81\u7684\u9519\u8bef\u3002\u4f8b\u5982\uff1a\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u914d\u7f6epidfile\uff0c\u90a3\u4e48\u542f\u52a8\u53c2\u6570\u4e2d\u5982\u679c\u6709\u2013pidfile , \u5219\u63d0\u793a\uff1a<\/p>\n<pre>unable to configure the Docker daemon with file \/usr\/local\/docker\/daemon.json: the\r\nfollowing directives are specified both as a flag and in the configuration file:\r\npidfile: (from flag: \/var\/run\/docker\/docker.pid, from file: \/var\/run\/docker\/docker.pid)<\/pre>\n<table cellspacing=\"5\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"20%\">\u2013config-file\u00a0&lt;file&gt;<\/td>\n<td valign=\"top\">\u00a0\u914d\u7f6e\u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013debug, -D<\/td>\n<td valign=\"top\">\u542f\u7528debug\u7684\u6a21\u5f0f\uff0c\u542f\u7528\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u7684\u542f\u52a8\u4fe1\u606f\u3002\u9ed8\u8ba4 false<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013pidfile, -p<\/td>\n<td valign=\"top\">pid\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013registry-mirror<\/td>\n<td valign=\"top\">\u955c\u50cf\u52a0\u901f\u7684\u5730\u5740\uff0c\u589e\u52a0\u540e\u5728 docker info \u4e2d\u53ef\u67e5\u770b<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013help<\/td>\n<td valign=\"top\">\u6253\u5370\u5e2e\u52a9\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013graph, -g<\/td>\n<td valign=\"top\">\u5df2\u5e9f\u5f03\uff0c\u4f7f\u7528\u2013data-root\u4ee3\u66ff<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013data-root<\/td>\n<td valign=\"top\">Docker\u8fd0\u884c\u65f6\u4f7f\u7528\u7684\u6839\u8def\u5f84,\u6839\u8def\u5f84\u4e0b\u7684\u5185\u5bb9\u7a0d\u540e\u4ecb\u7ecd\uff0c\u9ed8\u8ba4\/var\/lib\/docker<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013group=docker<\/td>\n<td valign=\"top\">Unix\u5957\u63a5\u5b57\u7684\u5c5e\u7ec4,\u4ec5\u6307\/var\/run\/docker.sock,\u5728\u540e\u53f0\u8fd0\u884c\u6a21\u5f0f\u4e0b\uff0c\u8d4b\u4e88\u6307\u5b9a\u7684Group\u5230\u76f8\u5e94\u7684unix socket\u4e0a\u3002\u6ce8\u610f\uff0c\u5f53\u6b64\u53c2\u6570 \u2013group \u8d4b\u4e88\u7a7a\u5b57\u7b26\u4e32\u65f6\uff0c\u5c06\u53bb\u9664\u7ec4\u4fe1\u606f\u3002<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">-H, \u2013host<\/td>\n<td valign=\"top\"><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013dns<\/td>\n<td valign=\"top\">\u8bbe\u5b9a\u5bb9\u5668\u7684DNS\u5730\u5740\uff0c\u5728\u5bb9\u5668\u7684 \/etc\/resolv.conf \u6587\u4ef6\u4e2d\u53ef\u67e5\u770b\u3002\u6ce8\u610f\uff1a\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c Docker \u4f1a\u9ed8\u8ba4\u7528\u4e3b\u673a\u4e0a\u7684 \/etc\/resolv.conf \u6765\u914d\u7f6e\u5bb9\u5668\u3002<br \/>\n[root@110 ~]# docker run -it \u2013dns=114.114.114.114 \u2013dns=8.8.8.8 centos bash -c \u201ccat \/etc\/resolv.conf\u201d<br \/>\nsearch 100.com<br \/>\nnameserver 114.114.114.114<br \/>\nnameserver 8.8.8.8<br \/>\n\u4f8b\u5982\uff1a<br \/>\n[root@110 ~]# docker run -it centos bash -c \u201ccat \/etc\/resolv.conf\u201d<br \/>\nsearch 100.com<br \/>\nnameserver 192.168.80.1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013dns-search<\/td>\n<td valign=\"top\">\u8bbe\u5b9a\u5bb9\u5668\u7684\u641c\u7d22\u57df\uff0c\u5f53\u8bbe\u5b9a\u641c\u7d22\u57df\u4e3a .example.com \u65f6\uff0c\u5728\u641c\u7d22\u4e00\u4e2a\u540d\u4e3a host \u7684 \u4e3b\u673a\u65f6\uff0cDNS \u4e0d\u4ec5\u641c\u7d22host\uff0c\u8fd8\u4f1a\u641c\u7d22 host.example.com \u3002 \u6ce8\u610f\uff1a\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c Docker \u4f1a\u9ed8\u8ba4\u7528\u4e3b\u673a\u4e0a\u7684 \/etc\/resolv.conf \u6765\u914d\u7f6e\u5bb9\u5668\u3002<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013dns-opt<\/td>\n<td valign=\"top\">\u5bb9\u5668 \/etc\/resolv.conf \u6587\u4ef6\uff0c\u5176\u4ed6\u8bbe\u7f6e<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013selinux-enabled<\/td>\n<td valign=\"top\">\u9ed8\u8ba4 false\uff0c\u542f\u7528selinux\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013tls<\/td>\n<td valign=\"top\">\u9ed8\u8ba4 false, \u542f\u52a8TLS\u8ba4\u8bc1\u5f00\u5173<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013tlscacert<\/td>\n<td valign=\"top\">\u9ed8\u8ba4 ~\/.docker\/ca.pem \uff0c\u901a\u8fc7CA\u8ba4\u8bc1\u8fc7\u7684\u7684certificate\u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013tlscert<\/td>\n<td valign=\"top\">\u9ed8\u8ba4 ~\/.docker\/cert.pem \uff0cTLS\u7684certificate\u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013tlskey<\/td>\n<td valign=\"top\">\u9ed8\u8ba4 ~\/.docker\/key.pem\uff0cTLS\u7684key\u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013tlsverify<\/td>\n<td valign=\"top\">\u9ed8\u8ba4false\uff0c\u4f7f\u7528TLS\u5e76\u505a\u540e\u53f0\u8fdb\u7a0b\u4e0e\u5ba2\u6237\u7aef\u901a\u8baf\u7684\u9a8c\u8bc1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">-v, \u2013version<\/td>\n<td valign=\"top\">\u9ed8\u8ba4false\uff0c\u663e\u793a\u7248\u672c\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013ip-forward<\/td>\n<td valign=\"top\">\u9ed8\u8ba4true, \u542f\u7528 net.ipv4.ip_forward ,\u8fdb\u5165\u5bb9\u5668\u540e\u4f7f\u7528 sysctl -a | grep net.ipv4.ip_forward \u67e5\u770b<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">\u2013label<\/td>\n<td valign=\"top\">docker\u4e3b\u673a\u7684\u6807\u7b7e\uff0c\u5f88\u5b9e\u7528\u7684\u529f\u80fd<br \/>\n\u4f8b\u5982\u5b9a\u4e49\uff1a\u2013label nodeName=host-121<br \/>\nlabel \u4f7f\u7528\u65b9\u6cd5\u53c2\u8003\uff1aDocker\u7684\u547d\u4ee4\u4e4b\u96c6\u7fa4\u670d\u52a1\u7ba1\u7406 Service<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">aaaa<\/td>\n<td valign=\"top\">bbbbb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u52a8\u7684docker\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u662fdockerd\uff0c\u9996\u5148\u9700\u8981\u77e5\u9053 dockerd \u7684\u6587\u4ef6\u8def\u5f84\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528 &lt;path&gt;\/dockerd &amp; \u542f\u52a8docker\uff0c\u8fd9\u91cc\u8be6\u7ec6\u4ecb\u7ecd\u4e0b\u542f\u52a8\u53c2\u6570\u7684\u4f7f\u7528\u3002 &nbsp; Tips 1\uff1aDocker\u4e2d\u7684\u7ec4\u4ef6\u4ecb\u7ecd Tips 2\uff1aDocker\u7684\u914d\u7f6e\u6587\u4ef6 daemon.json \u8be6\u7ec6\u89e3 Tips 3\uff1a\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u914d\u7f6e\u6587\u4ef6 deamon.json \u4e2d\u914d\u7f6e\u9879\u76ee\uff0c\u5728\u542f\u52a8\u53c2\u6570\u4e2d\u540c\u6837\u9002\u7528\uff08\u4f1a\u6709\u4e9b\u8bb8\u4e0d\u540c\uff09\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u7684\u4e00\u70b9\uff0c\u914d\u7f6e\u6587\u4ef6\u4e2d\u5982\u679c\u5df2\u7ecf\u6709\u67d0\u4e2a\u914d\u7f6e\u9879\uff0c\u5219\u65e0\u6cd5\u5728\u542f\u52a8\u53c2\u6570\u4e2d\u589e\u52a0\uff0c\u4f1a\u51fa\u73b0\u51b2\u7a81\u7684\u9519\u8bef\u3002\u4f8b\u5982\uff1a\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u914d\u7f6epidfile\uff0c\u90a3\u4e48\u542f\u52a8\u53c2\u6570\u4e2d\u5982\u679c\u6709\u2013pidfile , \u5219\u63d0\u793a\uff1a unable to configure the Docker daemon with file \/usr\/local\/docker\/daemon.json: the following directives are specified both as a flag and in the configuration file: pidfile: (from flag: \/var\/run\/docker\/docker.pid, from file: \/var\/run\/docker\/docker.pid) \u2013config-file\u00a0&lt;file&gt; \u00a0\u914d\u7f6e\u6587\u4ef6\u8def\u5f84 \u2013debug, -D \u542f\u7528debug\u7684\u6a21\u5f0f\uff0c\u542f\u7528\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u7684\u542f\u52a8\u4fe1\u606f\u3002\u9ed8\u8ba4 false [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-15513","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=15513"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15513\/revisions"}],"predecessor-version":[{"id":15514,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15513\/revisions\/15514"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=15513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=15513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=15513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}