{"id":427907,"date":"2021-04-18T09:18:19","date_gmt":"2021-04-18T01:18:19","guid":{"rendered":"http:\/\/4563.org\/?p=427907"},"modified":"2021-04-18T09:18:19","modified_gmt":"2021-04-18T01:18:19","slug":"%e9%97%ae%e9%a2%98%e5%b7%b2%e8%a7%a3%e5%86%b3%ef%bd%9c%e5%90%8e%e7%bb%ad-docker-%e5%ae%b9%e5%99%a8%e8%83%bd-ping-%e9%80%9a-ip-%e4%bd%86-ping-%e4%b8%8d%e9%80%9a%e5%9f%9f%e5%90%8d%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=427907","title":{"rendered":"[\u95ee\u9898\u5df2\u89e3\u51b3\uff5c\u540e\u7eed] docker \u5bb9\u5668\u80fd PING \u901a IP \u4f46 PING \u4e0d\u901a\u57df\u540d\u95ee\u9898\u7684\u6392\u67e5\u7ecf\u5386\u5206\u4eab"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [\u95ee\u9898\u5df2\u89e3\u51b3\uff5c\u540e\u7eed] docker \u5bb9\u5668\u80fd PING \u901a IP \u4f46 PING \u4e0d\u901a\u57df\u540d\u95ee\u9898\u7684\u6392\u67e5\u7ecf\u5386\u5206\u4eab               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AllenHua <\/span>  <span><i><\/i> 13<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7f16\u8f91\u597d\u4e86\u2026\u2026 v \u7ad9\u4e0d\u8ba9\u6211\u53d1\uff0c\u5c31\u5206\u4eab\u8fd9\u4e2a\u94fe\u63a5\u4e86\uff0c\u5199\u5728\u4e86\u535a\u6587\u4e2d<\/p>\n<p>\u524d\u60c5\u63d0\u8981\uff1a https:\/\/www.v2ex.com\/t\/769968<\/p>\n<p>[\u5df2\u89e3\u51b3] \u8bb0\u4e00\u6b21 docker \u5bb9\u5668\u5185\u80fd ping \u901a ip \u4f46 ping \u4e0d\u901a\u57df\u540d\u95ee\u9898\u7684\u6392\u67e5\u7ecf\u8fc7 https:\/\/hellodk.cn\/post\/496<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>12<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5737024\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vivisidea <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd8\u6ca1\u770b\uff0c\u76f2\u731c daemon.json \u914d\u7f6e\u4e86 iptables: false                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737025\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vivisidea <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6bd4\u6211\u60f3\u8c61\u7684\u590d\u6742\u4e00\u70b9\uff0c\u4e4b\u524d\u78b0\u5230\u8fc7\u914d\u7f6e\u4e86 iptables: false \u73b0\u8c61\u8ddf\u4f60\u8fd9\u4e2a\u4e00\u6837\uff0c\u624b\u52a8\u52a0\u9632\u706b\u5899\u89c4\u5219\u5c31\u884c\u4e86<\/p>\n<p>\u7406\u8bba\u4e0a\u8bf4\u914d\u7f6e\u4e86 iptables: true\uff0cdocker \u4f1a\u81ea\u52a8\u52a0\u9632\u706b\u5899\u89c4\u5219\u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737026\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Sasasu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             TL;DR<\/p>\n<p>1. \u6ca1\u6709\u914d\u7f6e udp \u8f6c\u53d1<br \/>2. \u81ea\u5efa dns \u6ca1\u6709\u63a5\u53d7\u6765\u81ea docker \u7f51\u5361\u7684\u67e5\u8be2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737027\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CallMeReznov <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u4e4b\u524d\u518d\u673a\u623f\u5f97\u65f6\u5019\u9047\u5230\u8fc7\u4e00\u6b21,\u5916\u5305\u5f00\u53d1\u90e8\u7f72\u5f97\u7cfb\u7edf\u548c docker. <br \/>\u4ed6\u4eec\u8bf4\u7f51\u7edc\u5f02\u5e38,\u7136\u540e\u5c31\u88c5\u6b7b\u4e0d\u89e3\u51b3\u4e86,\u6ca1\u529e\u6cd5\u6211\u4eb2\u81ea\u4e0a\u53bb\u6392\u67e5.<br \/>\u5f53\u65f6\u76f4\u63a5\u5148\u67e5\u8def\u7531\u8fd8\u6709 ping \u53d1\u73b0\u5168\u6253\u5230\u672c\u5730\u4e0a\u4e86,\u4e8e\u662f\u6000\u7591\u662f\u4e0d\u662f\u8def\u7531\u8868\u6216\u8005\u865a\u62df IP \u5bfc\u81f4\u5f97,ip addr \u4e00\u4e0b\u679c\u7136\u662f docker \u5f97\u9ed8\u8ba4 bridge \u4e0e\u5b9e\u9645\u7f51\u5361\u5730\u5740\u6bb5\u51b2\u7a81\u4e86.\u544a\u8bc9\u5f00\u53d1\u8ba9\u4ed6\u4eec\u4fee\u6539 docker0 \u5f97\u9ed8\u8ba4\u5730\u5740\u6bb5\u91cd\u542f\u5c31\u89e3\u51b3\u4e86.<\/p>\n<p>\u8fd8\u6709\u5c31\u662f wsl \u6bcf\u6b21\u91cd\u542f\u4e5f\u4f1a\u968f\u673a\u5206\u914d IP,\u5076\u5c14\u4e5f\u4f1a\u5206\u914d\u5230 172.1X 2X 3X \u5f97\u5730\u5740\u6bb5\u4e0a,\u4e5f\u662f\u4e2a\u5751,\u5f97\u6ce8\u610f.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737028\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AllenHua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vivisidea #2 \u662f\u7684 \u4f46\u6211\u4e00\u5f00\u59cb\u5b9e\u5728\u662f\u4e0d\u77e5\u9053\u8fd9\u4e2a\u56fa\u4ef6\u7684 docker \u914d\u7f6e \u4ee5\u53ca dockerd \u7684\u542f\u52a8\u811a\u672c\u5c31\u6709\u95ee\u9898 \uff08 \/etc\/config\/docker \u548c \/etc\/init.d\/dockerd \uff09<br \/>\u914d\u7f6e\u4e86 iptables true docker \u4f1a\u5728\u9632\u706b\u5899\u4e0a\u6dfb\u52a0\u5bf9\u5e94\u89c4\u5219<\/p>\n<p>@Sasasu #3 \u662f\u7684\u603b\u7ed3\u7684\u5f88\u597d \u95ee\u9898\u5c31\u4e24\u4e2a \u4e00\u4e2a iptables \u4e00\u4e2a\u81ea\u5efa dns \u6ca1\u6709\u76d1\u542c\u6765\u81ea docker \u7f51\u5361\u7684\u67e5\u8be2\u8bf7\u6c42<\/p>\n<p>@CallMeReznov #4 \u6240\u4ee5\u80fd\u81ea\u5b9a\u4e49 cidr \u7684 subnet ip-range gateway \u8fd9\u4e9b\u7684 \u53ef\u4ee5\u81ea\u5b9a\u4e49 \u514d\u5f97\u51b2\u7a81                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737029\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhangsanfeng2012 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8ddf\u6211\u60f3\u7684\u4e00\u6837<br \/>\u4f46\u662f\u6309\u7406\u8bf4\uff0c\u4f60\u628a openwrt \u7684 53 \u7aef\u53e3\u91cd\u5b9a\u5411\u5173\u6389\uff0c\u4e5f\u5e94\u8be5\u4f1a\u901a\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737030\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AllenHua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhangsanfeng2012 #6 \u5f53\u65f6\u5220\u6389\u4e86\u54ea\u4e24\u6761 iptables \u89c4\u5219\u4e0d\u592a\u8bb0\u5f97\u4e86<\/p>\n<p>\u603b\u4e4b\u4ea4\u7ed9\u8c01\u67e5\u8be2 \u4e2d\u95f4\u73af\u8282\u8fd8\u662f\u8981\u91cd\u70b9\u5173\u6ce8\u4e86 \uff08\u7ecf\u9a8c+1                                                             <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737031\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : naruco <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @AllenHua subnet \u7684 ip-range \u662f\u600e\u4e48\u505a\u5230\u81ea\u5b9a\u4e49\u7684\uff0c\u80fd\u5426\u5206\u4eab\u4e00\u4e0b\uff1f\u8c22\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737032\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AllenHua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @naruco #8 <\/p>\n<p>&#8220;`<br \/>$ docker network create <br \/> &#8211;driver=bridge <br \/> &#8211;subnet=172.28.0.0\/16 <br \/> &#8211;ip-range=172.28.5.0\/24 <br \/> &#8211;gateway=172.28.5.254 <br \/> mynetwork<br \/>&#8220;`<\/p>\n<p>\u6765\u81ea https:\/\/docs.docker.com\/engine\/reference\/commandline\/network_create\/#specify-advanced-options<\/p>\n<p>&#8211;driver \u6307\u5b9a\u4f7f\u7528\u7684\u9a71\u52a8 \u6709\u56db\u79cd\u53ef\u9009\u9879 Driver to manage the Network (default &#8220;bridge&#8221;)<br \/>&#8211;subnet \u5b50\u7f51\u7684\u89c4\u5212\uff0c\u4f7f\u7528 cidr \u683c\u5f0f\uff0c\u4e0a\u9762\u7f51\u7edc 172.28.0.0\uff0c\u63a9\u7801 16 \u3002\u5b98\u65b9\u89e3\u91ca\u662f Subnet in CIDR format that represents a network segment<br \/>&#8211;ip-range \u8fd9\u4e2a\u7f51\u7edc\u5212\u5206\u8303\u56f4\u8981\u6bd4\u4e0a\u9762\u7684\u5b50\u7f51\u8981\u5c0f\uff0c\u7136\u540e\u5206\u914d\u7684\u5bb9\u5668\u4f7f\u7528\u8fd9\u4e9b ip \u5730\u5740\u3002\u5b98\u65b9\u8fd9\u4e2a\u53c2\u6570\u89e3\u91ca\u662f Allocate container ip from a sub-range<br \/>&#8211;gateway \u6307\u5b9a\u8be5\u7f51\u7edc\u7684\u7f51\u5173\u5730\u5740 IPv4 or IPv6 Gateway for the master subnet<\/p>\n<p>\u4e0a\u9762\u7684 &#8211;ip-range \u5b9a\u4e49\u4e86 172.28.5.0\/24 \u8fd9\u4e2a\u7f51\u7edc\u7ed9\u4f7f\u7528\u8fd9\u4e2a network \u7684\u5bb9\u5668\u4f7f\u7528\uff0c\u8fd9\u4e9b\u5bb9\u5668\u7684 ip \u5206\u914d\u5c06\u4ece 172.28.5.1\/24 \u5f00\u59cb\uff0c\u6700\u591a\u5206\u914d\u5230 172.28.5.253\/24\uff0c\u6240\u4ee5\u7528\u6237\u521b\u5efa\u7684\u8fd9\u4e2a user-defined network \u6700\u591a\u80fd\u5206\u914d\u7ed9 253 \u4e2a docker \u5bb9\u5668\u3002172.28.5.0 \u662f\u8fd9\u4e2a\u7f51\u7edc\uff0c\u7f51\u5173\u662f 172.28.5.254 \uff0c172.28.5.255 \u662f\u5e7f\u64ad\u5730\u5740                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737033\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AllenHua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @naruco #8 \u6211\u521a\u6d4b\u8bd5\u4e86\u4e00\u4e0b \u53d1\u73b0 docker \u4e2d\u7684\u5bb9\u5668 \u4f7f\u7528\u81ea\u5b9a\u4e49 bridge \u7f51\u7edc\uff0c\u7b2c\u4e00\u4e2a\u5bb9\u5668\u7684 ip \u5730\u5740\u662f\u4ece 0 \u5f00\u59cb\u7684\uff08\u4e0d\u662f\u4ece 1 \uff09\uff0c\u4e5f\u5c31\u662f\u8bf4\u7ed9\u7b2c\u4e00\u4e2a\u4f7f\u7528\u8fd9\u4e2a network \u7684\u5bb9\u5668\u5206\u914d\u7684 ip \u662f 172.28.5.0\uff0c\u7f51\u5173\u662f 172.28.5.254 \uff0c\u63a9\u7801\u662f 16 \u4f4d\u3002\u4e0d\u8fc7\u4e00\u822c\u60c5\u51b5\u4e0b .0 \u4ee3\u8868\u672c\u7f51\u7edc\uff0c.255 \u4ee3\u8868\u5e7f\u64ad\u5730\u5740<\/p>\n<p>docker \u81ea\u5df1\u5b9e\u73b0\u7684 bridge \u7f51\u7edc\u4e2d\uff0c\u5bb9\u5668\u4e2d\u7684\u63a5\u53e3\u548c\u5728\u5bbf\u4e3b\u673a\u4e0a\u751f\u6210\u7684\u865a\u62df\u7f51\u7edc\u63a5\u53e3 \u5e7f\u64ad\u5730\u5740\u90fd\u662f 0.0.0.0\uff0czero network\uff0c\u4ee3\u8868\u672c\u673a\u4e0a\u7684\u6240\u6709 ipv4 \u5730\u5740                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737034\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : naruco <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @AllenHua <br \/>\u6700\u8fd1\u4e5f\u5728\u6478\u7d22\u8fd9\u4e9b\uff0c\u73af\u5883 win10, hyper-v, wsl 2, docker-desktop<br \/>\u6b63\u597d\u5728 B \u7ad9\u770b\u4e86\u4e00\u96c6\u89c6\u9891\u8bb2\u5230 docker network\uff0c\u548c\u4f60\u8fd9\u4e00\u7ed3\u5408\uff0c\u5370\u8c61\u6df1\u523b\uff01\u975e\u5e38\u611f\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5737035\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AllenHua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @naruco #11 \u5ba2\u6c14\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[\u95ee\u9898\u5df2\u89e3\u51b3\uff5c\u540e\u7eed] docker&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/427907"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427907"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/427907\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427907"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}