{"id":983,"date":"2023-02-15T14:27:47","date_gmt":"2023-02-15T06:27:47","guid":{"rendered":"https:\/\/www.jchj.top\/?p=983"},"modified":"2025-11-03T10:26:57","modified_gmt":"2025-11-03T02:26:57","slug":"docker%e5%ae%b9%e5%99%a8%e7%bd%91%e7%bb%9c","status":"publish","type":"post","link":"https:\/\/www.jchj.top\/?p=983","title":{"rendered":"docker\u5bb9\u5668\u7f51\u7edc"},"content":{"rendered":"\n<p>\u5bb9\u5668\u7684\u56db\u79cd\u7f51\u7c7b bridge: -net=bridge <strong>\u6865\u63a5\u5f0f\u7f51\u8def<\/strong>\uff1a\u8fd9\u91cc\u7684\u6865\u63a5\u7f51\u7edc\u4e0d\u662f\u7269\u7406\u6865\u63a5\uff0c\u6307\u7684\u662fnat\u6865\u63a5\uff0cbridge\u6a21\u5f0f\u662fdocker\u7684\u9ed8\u8ba4\u7f51\u7edc\u6a21\u5f0f\u5730\u5740\u662f172.17.0*\u7f51\u6bb5\uff0c\u4e0d\u5199&#8211;net\u53c2\u6570\uff0c\u5c31\u662fbridge\u6a21\u5f0f\u3002<\/p>\n\n\n\n<p>Host: -net=host <strong>\u4e3b\u673a\u5f0f\u7f51\u7edc<\/strong>\uff1a\u5bb9\u5668\u4e0e\u5bbf\u4e3b\u673a\u5171\u7528\u4e00\u4e2aNetwork Namespace\u3002\u5bb9\u5668\u5c06\u4e0d\u4f1a\u865a\u62df\u51fa\u81ea\u5df1\u7684\u7f51\u5361\uff0c\u914d\u7f6e\u81ea\u5df1\u7684IP\u7b49\uff0c\u800c\u662f\u4f7f\u7528\u5bbf\u4e3b\u673a\u7684IP\u548c\u7aef\u53e3\u3002\u4f46\u662f\uff0c\u5bb9\u5668\u7684\u5176\u4ed6\u65b9\u9762\uff0c\u5982\u6587\u4ef6\u7cfb\u7edf\u3001\u8fdb\u7a0b\u5217\u8868\u7b49\u8fd8\u662f\u548c\u5bbf\u4e3b\u673a\u9694\u79bb\u7684\u3002<\/p>\n\n\n\n<p>container: -net=container:NAME_or_ID <strong>\u8054\u76df\u5f0f\u7f51\u7edc<\/strong>\uff1a \u8fd9\u4e2a\u6a21\u5f0f\u6307\u5b9a\u65b0\u521b\u5efa\u7684\u5bb9\u5668\u548c\u5df2\u7ecf\u5b58\u5728\u7684\u4e00\u4e2a\u5bb9\u5668\u5171\u4eab\u4e00\u4e2a Network Namespace\uff0c\u800c\u4e0d\u662f\u548c\u5bbf\u4e3b\u673a\u5171\u4eab\u3002\u65b0\u521b\u5efa\u7684\u5bb9\u5668\u4e0d\u4f1a\u521b\u5efa\u81ea\u5df1\u7684\u7f51\u5361\uff0c\u914d\u7f6e\u81ea\u5df1\u7684 IP\uff0c\u800c\u662f\u548c\u4e00\u4e2a\u6307\u5b9a\u7684\u5bb9\u5668\u5171\u4eab IP\u3001\u7aef\u53e3\u8303\u56f4\u3002<\/p>\n\n\n\n<p>none: -net=none <strong>\u5c01\u95ed\u5f0f\u7f51\u7edc<\/strong>\uff1a Docker\u5bb9\u5668\u62e5\u6709\u81ea\u5df1\u7684Network Namespace\uff0c\u8fd9\u4e2aDocker\u5bb9\u5668\u6ca1\u6709\u7f51\u5361(\u53ea\u6709 lo \u56de\u73af\u7f51\u7edc)\u3001IP\u3001\u8def\u7531\u7b49\u4fe1\u606f\u3002\u9700\u8981\u6211\u4eec\u81ea\u5df1\u4e3aDocker\u5bb9\u5668\u6dfb\u52a0\u7f51\u5361\u3001\u914d\u7f6eIP\u7b49\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"103\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280.png\" alt=\"\" class=\"wp-image-1566\"\/><\/figure>\n\n\n\n<p>\u5bb9\u5668\u9ed8\u8ba4\u7684\u6865\u63a5\u7f51\u7edc\u662f172.17.0.1\uff0c\u6bcf\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668\u5c06\u9ed8\u8ba4\u5206\u914d\u4e00\u4e2a172.17.0\u7f51\u6bb5\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1193\" height=\"798\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280-1.png\" alt=\"\" class=\"wp-image-1560\"\/><\/figure>\n\n\n\n<p>\u5b89\u88c5bridge-utils\u5de5\u5177\u67e5\u770b\u7f51\u7edc\u4ea4\u63a5\u60c5\u51b5<\/p>\n\n\n\n<p>[root@localhost ~]# yum install bridge-utils<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"414\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280-2.png\" alt=\"\" class=\"wp-image-1561\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# brctl show \u663e\u793a\u6865\u63a5\u4e86\u4e09\u5757\u7f51\u5361\uff08\u5df2\u542f\u52a8\u4e09\u4e2a\u5bb9\u5668\uff09<\/p>\n\n\n\n<p>[root@localhost ~]# docker inspect bridge \uff08\u53ef\u67e5\u770b\u9ed8\u8ba4bridge\u7f51\u7edc\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1082\" height=\"109\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280-3.png\" alt=\"\" class=\"wp-image-1562\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker container inspect tt \u67e5\u770b\u5bb9\u5668\u7f51\u7edc<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"634\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280-4.png\" alt=\"\" class=\"wp-image-1563\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name by -it &#8211;network bridge busybox:latest \u6307\u5b9abridge\u7f51\u7edc\u6a21\u5f0f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"453\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280-5.png\" alt=\"\" class=\"wp-image-1564\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name by -it &#8211;network none busybox:latest \u6307\u5b9anone\u7f51\u7edc\u6a21\u5f0f\uff0c\u8fd9\u4e2aDocker\u5bb9\u5668\u6ca1\u6709\u7f51\u5361\u79f0\u4e3a\u5c01\u95ed\u5f0f\u5bb9\u5668\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1132\" height=\"260\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/1280X1280-6.png\" alt=\"\" class=\"wp-image-1565\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name by -it &#8211;network bridge -h jchj &#8211;dns 8.8.8.8 busybox:latest<\/p>\n\n\n\n<p>\u542f\u52a8\u5bb9\u5668\u65f6\u6307\u5b9a\u5176\u5bb9\u5668\u540d\u79f0\u3001\u7f51\u7edc\u7c7b\u578b\u3001\u4e3b\u673a\u540d\u3001DNS\u5730\u5740\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"311\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/0cbef276-57ff-4b4e-bced-54d15c5e0362.png\" alt=\"\" class=\"wp-image-1553\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name by -it &#8211;network bridge -h jchj &#8211;dns 8.8.8.8 &#8211;add-host www.jchj.shop:10.0.0.101 busybox:latest \u6307\u5b9aIP\u89e3\u6790\u57df\u540d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"249\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/764956fc-2f0f-481b-b4f7-dd4377a3226a.png\" alt=\"\" class=\"wp-image-1568\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name jj -itd -p 32761:80 jchj\/httpd:v0.2 \u628ajj\u5bb9\u5668\u4e2d\u9700\u8981\u5bf9\u5916\u66b4\u9732\u768480\u7aef\u53e3\u6620\u5c04\u81f3\u5bbf\u4e3b\u673a\u768432761\u7aef\u53e3\u4e0a\uff0c\u56e0\u6b64\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u8bbf\u95ee\u5bbf\u4e3b\u673acurl 10.0.0.101:32761\u6765\u8bbf\u95ee\u5bb9\u5668\u5185\u7684http\u670d\u52a1\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"135\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/8a09907d-a67e-497f-88e7-fbe48373fa21.png\" alt=\"\" class=\"wp-image-1556\"\/><\/figure>\n\n\n\n<p><strong>\u4e3b\u673a\u662f\u7f51\u7edc\uff1a<\/strong>\u5bb9\u5668\u4e0e\u5bbf\u4e3b\u673a\u5171\u7528\u4e00\u4e2aNetwork Namespace\u3002\u5bb9\u5668\u5c06\u4e0d\u4f1a\u865a\u62df\u51fa\u81ea\u5df1\u7684\u7f51\u5361\uff0c\u914d\u7f6e\u81ea\u5df1\u7684IP\u7b49\uff0c\u800c\u662f\u4f7f\u7528\u5bbf\u4e3b\u673a\u7684IP\u548c\u7aef\u53e3\u3002<\/p>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name b2 &#8211;network host -it busybox<\/p>\n\n\n\n<p>(\u5bbf\u4e3b\u673a\u7684\u7f51\u7edc\u5730\u5740\u4e5f\u662f10.0.0.80)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"619\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/cbca7fe4-8e69-4926-81c6-dda2cdf40e6d.png\" alt=\"\" class=\"wp-image-1573\"\/><\/figure>\n\n\n\n<p><strong>\u6865\u63a5\u5f0f\u7f51\u8def<\/strong>\uff1a\u8fd9\u91cc\u7684\u6865\u63a5\u7f51\u7edc\u4e0d\u662f\u7269\u7406\u6865\u63a5\uff0c\u6307\u7684\u662fnat\u6865\u63a5\uff0cbridge\u6a21\u5f0f\u662fdocker\u7684\u9ed8\u8ba4\u7f51\u7edc\u6a21\u5f0f\u5730\u5740\u662f172.17.0*\u7f51\u6bb5<\/p>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name b2 &#8211;network bridge -it busybox<\/p>\n\n\n\n<p>(\u8fd9\u91cc&#8211;network \u6307\u4e0d\u6307\u660ebridge\u90fd\u4e00\u6837\uff0c\u5bb9\u5668\u9ed8\u8ba4\u5373\u662fnet\u6865\u63a5\u7f51\u7edc\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1258\" height=\"452\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/9d426846-84bb-4acd-b857-8de5e356f01e.png\" alt=\"\" class=\"wp-image-1558\"\/><\/figure>\n\n\n\n<p><strong>\u5c01\u95ed\u5f0f\u7f51\u7edc<\/strong>\uff1a Docker\u5bb9\u5668\u62e5\u6709\u81ea\u5df1\u7684Network Namespace\uff0c\u8fd9\u4e2aDocker\u5bb9\u5668\u6ca1\u6709\u7f51\u5361(\u53ea\u6709 lo \u56de\u73af\u7f51\u7edc)<\/p>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name b2 &#8211;network none -it busybox<\/p>\n\n\n\n<p>(IP\u3001\u8def\u7531\u7b49\u4fe1\u606f\u3002\u540e\u9762\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u4e3aDocker\u5bb9\u5668\u6dfb\u52a0\u7f51\u5361\u3001\u914d\u7f6eIP\u7b49)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1138\" height=\"284\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/beaa6f08-d697-4666-bd4b-1c7b72cde1e4.png\" alt=\"\" class=\"wp-image-1571\"\/><\/figure>\n\n\n\n<p><strong>\u8054\u76df\u5f0f\u5bb9\u5668<\/strong>\uff1a\u8fd9\u4e2a\u6a21\u5f0f\u6307\u5b9a\u65b0\u521b\u5efa\u7684\u5bb9\u5668\u548c\u5df2\u7ecf\u5b58\u5728\u7684\u4e00\u4e2a\u5bb9\u5668\u5171\u4eab\u4e00\u4e2a Network Namespace\uff0c\u800c\u4e0d\u662f\u548c\u5bbf\u4e3b\u673a\u5171\u4eab\u3002\u76f8\u5f53\u4e8e\u4e00\u4e2a\u4e3b\u673a\u4e0a\u8dd1\u591a\u4e2a\u8fdb\u7a0b\u5982\uff1a\u4e00\u4e2a\u4e3b\u673a\u8dd1\u6709nginx\u3001mysql\u6216\u662fphp\u7b49\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>\u8fd0\u884c\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u5bb9\u5668\uff1a<\/p>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name b1 -it busybox<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"475\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/c212fc9b-13e2-430b-b3c7-a3b9f94f4274.png\" alt=\"\" class=\"wp-image-1572\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name b2 &#8211;network container:b1 -it busybox<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"553\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/8d69cf21-c73c-401b-bb78-08cc5ae7e083.png\" alt=\"\" class=\"wp-image-1557\"\/><\/figure>\n\n\n\n<p><strong>\u81ea\u5b9a\u4e49docker0\u6865\u7684\u7f51\u7edc\u5c5e\u6027\u4fe1\u606f<\/strong>\uff08\u4e5f\u5c31\u662f\u6539\u53d8\u9ed8\u8ba4docker0\u7684\u6865\u63a5\u7684172.17.0.*\u7f51\u7edc\u5730\u5740\u6bb5\uff09<\/p>\n\n\n\n<p>\u66f4\u6539docker0\u6865\u7684\u7f51\u7edc\u5c5e\u6027\u4fe1\u606f\uff1a\/etc\/docker\/daemon.json<\/p>\n\n\n\n<p>&#8220;bip&#8221;:&#8221;192.168.100.1\/24&#8243;, bip\u5373bridge ip \u4e4b\u610f\uff0c\u7528\u4e8e\u6307\u5b9adocker0\u6865\u81ea\u8eab\u7684IP\u5730\u5740\uff0c\u5176\u5b83\u9009\u9879\u53ef\u901a\u8fc7\u6b64\u5730\u5740\u8ba1\u7b97\u5f97\u51fa<\/p>\n\n\n\n<p>&#8220;fixed-cidr&#8221;:&#8221;10.20.0.0\/16&#8243;, \u6307\u5b9a\u9ed8\u8ba4IPV4\u5730\u5740<\/p>\n\n\n\n<p>&#8220;fixed-cidr-v6&#8243;:&#8221;2001:d8::\/64&#8221;, \u6307\u5b9a\u9ed8\u8ba4IPV6\u5730\u5740<\/p>\n\n\n\n<p>&#8220;mtu&#8221;:1500,<\/p>\n\n\n\n<p>&#8220;default-gateway&#8221;:&#8221;10.20.1.1&#8243;, \u6307\u5b9a\u9ed8\u8ba4IPV4\u5730\u5740\u7f51\u5173<\/p>\n\n\n\n<p>&#8220;default-gateway-v6&#8243;:&#8221;2001:db8:abcd::89&#8221;, \u6307\u5b9a\u9ed8\u8ba4IPV6\u5730\u5740\u7f51\u5173<\/p>\n\n\n\n<p>&#8220;dns&#8221;:{&#8220;114.114.114.114&#8243;,&#8221;10.20.1.3&#8221;}, \u6307\u5b9aDNS\u5730\u5740<\/p>\n\n\n\n<p>\u6b64\u5904\u6211\u4eec\u4e00\u822c\u53ea\u6307\u5b9abip\u5730\u5740\u5373\u53ef.<\/p>\n\n\n\n<p>[root@localhost ~]# vim \/etc\/docker\/daemon.json<\/p>\n\n\n\n<p>\uff08\u5728\u5bb9\u5668\u52a0\u901f\u5668\u5730\u5740\u540e\u9762\u52a0\u4e0a&#8221;bip&#8221;:&#8221;192.168.100.1\/24&#8243;\u4fdd\u5b58\u9000\u51fa\u91cd\u542f\u5bb9\u5668\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"356\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/e5f0e6cf-439f-40ff-8072-3d2b20e5b4b0.png\" alt=\"\" class=\"wp-image-1574\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# systemctl restart docker \u91cd\u542f\u5bb9\u5668<\/p>\n\n\n\n<p>[root@localhost ~]# docker run &#8211;name b2 &#8211;network bridge -it busybox<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1230\" height=\"450\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/108a86e3-0765-41d1-9534-ed94b4b0c625.png\" alt=\"\" class=\"wp-image-1559\"\/><\/figure>\n\n\n\n<p>docker\u5b88\u62a4\u8fdb\u7a0b\u7684c\/s,\u5176\u9ed8\u8ba4\u4ec5\u76d1\u542cUnix S0cket\u683c\u5f0f\u7684\u5730\u5740\uff0c\/var\/run\/docker.sock;\u5982\u679c\u4f7f\u7528TCP\u5957\u63a5\u5b57\uff0c\/etc\/docker\/daemon.json<\/p>\n\n\n\n<p>&#8220;hosts&#8221;:[&#8220;tcp:\/\/0.0.0.0:2375&#8243;,&#8221;unix:\/\/\/var\/run\/docker.sock&#8221;]<\/p>\n\n\n\n<p>\uff08\u5373\u53ef\u901a\u8fc7\u5730\u5740\u8bbf\u95ee\uff0c&#8221;tcp:\/\/0.0.0.0:2375&#8243;\u9ed8\u8ba4\u76d1\u542c\u672c\u673a\u6240\u6709\u5730\u5740\u76842375\u7aef\u53e3\uff0c&#8221;unix:\/\/\/var\/run\/docker.sock&#8221;unix\u534f\u8bae\u8def\u5f84\uff09<\/p>\n\n\n\n<p>\u4e5f\u53ef\u5411docker\u76f4\u63a5\u4f20\u9012\u201d-H|&#8211;host&#8221;\u9009\u9879<\/p>\n\n\n\n<p>[root@localhost ~]# vim \/etc\/docker\/daemon.json<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"395\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/a0706915-da14-4fd4-a7c6-f5a3fe4026aa.png\" alt=\"\" class=\"wp-image-1569\"\/><\/figure>\n\n\n\n<p>[root@localhost ~]# systemctl restart docker \u91cd\u542f\u5bb9\u5668<\/p>\n\n\n\n<p>[root@localhost ~]# ss -tnl<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"144\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/afcb46e3-bd21-40f2-b7e3-88ea30825109.png\" alt=\"\" class=\"wp-image-1570\"\/><\/figure>\n\n\n\n<p>[root@js ~]# docker -H 10.0.0.80:2375 images \u8fde\u63a5\u8fdc\u7a0b\u4e3b\u673a\u7684docker<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"137\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/2c151ee4-1624-40b5-95cf-b34d784a9918.png\" alt=\"\" class=\"wp-image-1554\"\/><\/figure>\n\n\n\n<p>[root@js ~]# docker info \u5728docker\u7684\u4fe1\u606f\u4e2d\u53ef\u4ee5\u770b\u5230\u8fd8\u53ef\u4ee5\u521b\u5efaipvlan\u3001manvlan\u3001overlay\u7684\u6865\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1218\" height=\"810\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/580918f6-02ac-4170-93f0-4ddf556946e4.png\" alt=\"\" class=\"wp-image-1567\"\/><\/figure>\n\n\n\n<p>\u518d\u521b\u5efa\u4e00\u4e2abridge\u7684\u6865\u4f7f\u7528\u4e0d\u540c\u7684IP\u5730\u5740\u6bb5\uff0c\u5982\uff1adocker network create -d bridge &#8211;subnet &#8220;172.26.0.0\/16&#8221; &#8211;gateway &#8220;172.26.0.1&#8221; mybr0<\/p>\n\n\n\n<p>[root@localhost ~]# docker network create -d bridge &#8211;subnet &#8220;172.26.0.0\/16&#8221; &#8211;gateway &#8220;172.26.0.1&#8221; mybr0<\/p>\n\n\n\n<p>\u4e24\u4e2a\u4e0d\u540c\u7f51\u7edc\u5730\u5740\u6bb5\u7684bridge\u6865\u90fd\u662fnet\u6865\u63a5\u5230\u672c\u673a\u7684\u7269\u7406\u63a5\u53e3\u7684\uff0c\u5e94\u8be5\u662f\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\u7684\uff0c\u5982\u679c\u4e0d\u884c\u5c31\u5f00\u542f\u7cfb\u7edf\u7684\u6838\u5fc3\u8f6c\u53d1\u529f\u80fd\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1227\" height=\"300\" src=\"https:\/\/www.jchj.top\/wp-content\/uploads\/2025\/11\/4d63f199-1673-466e-b3d1-959ebe022127.png\" alt=\"\" class=\"wp-image-1555\"\/><\/figure>\n\n\n\n<p>CentOS7 \u5f00\u542f\u5185\u6838\u8f6c\u53d1<\/p>\n\n\n\n<p># vim \/etc\/sysctl.conf<\/p>\n\n\n\n<p>#\u6dfb\u52a0\u4ee5\u4e0b\u53c2\u6570<\/p>\n\n\n\n<p>net.ipv4.ip_forward=1 # 1\u8868\u793a\u5f00\u542f 0\u8868\u793a\u5173\u95ed<\/p>\n\n\n\n<p>net.ipv4.conf.default.rp_filter=0<\/p>\n\n\n\n<p>net.ipv4.conf.all.rp_filter=0 #\u63a7\u5236\u7cfb\u7edf\u662f\u5426\u5f00\u542f\u5bf9\u6570\u636e\u5305\u6e90\u5730\u5740\u7684\u6821\u9a8c<\/p>\n\n\n\n<p># rp_filter\u53c2\u6570\u6709\u4e09\u4e2a\u503c\uff0c0\u30011\u30012\uff0c\u5177\u4f53\u542b\u4e49\uff1a 0\uff1a\u4e0d\u5f00\u542f\u6e90\u5730\u5740\u6821\u9a8c\u3002 1\uff1a\u5f00\u542f\u4e25\u683c\u7684\u53cd\u5411\u8def\u5f84\u6821\u9a8c\u3002\u5bf9\u6bcf\u4e2a\u8fdb\u6765\u7684\u6570\u636e\u5305\uff0c\u6821\u9a8c\u5176\u53cd\u5411\u8def\u5f84\u662f\u5426\u662f\u6700\u4f73\u8def\u5f84\u3002\u5982\u679c\u53cd\u5411\u8def\u5f84\u4e0d\u662f\u6700\u4f73\u8def\u5f84\uff0c\u5219\u76f4\u63a5\u4e22\u5f03\u8be5\u6570\u636e\u5305\u3002 2\uff1a\u5f00\u542f\u677e\u6563\u7684\u53cd\u5411\u8def\u5f84\u6821\u9a8c\u3002\u5bf9\u6bcf\u4e2a\u8fdb\u6765\u7684\u6570\u636e\u5305\uff0c\u6821\u9a8c\u5176\u6e90\u5730\u5740\u662f\u5426\u53ef\u8fbe\uff0c\u5373\u53cd\u5411\u8def\u5f84\u662f\u5426\u80fd\u901a\uff08\u901a\u8fc7\u4efb\u610f\u7f51\u53e3\uff09\uff0c\u5982\u679c\u53cd\u5411\u8def\u5f84\u4e0d\u540c\uff0c\u5219\u76f4\u63a5\u4e22\u5f03\u8be5\u6570\u636e\u5305\u3002<\/p>\n\n\n\n<p>sysctl -p ##\u8ba9\u5185\u6838\u53c2\u6570\u7acb\u5373\u751f\u6548\uff0c\u52a0\u8f7dsysctl\u914d\u7f6e\u6587\u4ef6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bb9\u5668\u7684\u56db\u79cd\u7f51\u7c7b bridge: -net=brid&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,7],"tags":[],"class_list":["post-983","post","type-post","status-publish","format-standard","hentry","category-k8s-docker","category-7"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts\/983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=983"}],"version-history":[{"count":2,"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts\/983\/revisions"}],"predecessor-version":[{"id":1576,"href":"https:\/\/www.jchj.top\/index.php?rest_route=\/wp\/v2\/posts\/983\/revisions\/1576"}],"wp:attachment":[{"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jchj.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}