{"id":125543,"date":"2020-06-23T04:49:43","date_gmt":"2020-06-22T20:49:43","guid":{"rendered":"http:\/\/4563.org\/?p=125543"},"modified":"2020-06-23T04:49:43","modified_gmt":"2020-06-22T20:49:43","slug":"%e6%b1%82%e6%95%99%e5%9c%a8-docker-%e5%ae%b9%e5%99%a8%e5%86%85%e9%83%a8%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e5%ae%bf%e4%b8%bb%e6%9c%ba%e7%9a%84-ip","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=125543","title":{"rendered":"[\u6c42\u6559]\u5728 docker \u5bb9\u5668\u5185\u90e8\u5982\u4f55\u83b7\u53d6\u5bbf\u4e3b\u673a\u7684 ip"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [\u6c42\u6559]\u5728 docker \u5bb9\u5668\u5185\u90e8\u5982\u4f55\u83b7\u53d6\u5bbf\u4e3b\u673a\u7684 ip               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Ezez <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u9700\u6c42\uff1a\u5f00\u53d1\u4e00\u4e2a\u63d2\u4ef6\u7ed9\u901a\u8fc7 docker \u90e8\u7f72\u7684\u670d\u52a1\u96c6\u7fa4\u7528\uff0c\u63d2\u4ef6\u7684\u4e00\u4e2a\u529f\u80fd\u9700\u8981\u83b7\u53d6\u5230\u5bbf\u4e3b\u673a\u7684 ip<br \/>\u5df2\u77e5\uff1a\u53ef\u901a\u8fc7 k8s \u7b49\u7ba1\u7406 docker \u7684\u5de5\u5177\u83b7\u53d6\u5bbf\u4e3b\u673a ip<br \/>\u95ee\u9898\uff1a\u4e0d\u901a\u8fc7 k8s \u7b49\u7ba1\u7406\u5de5\u5177\u6709\u529e\u6cd5\u83b7\u53d6\u5230\u5bbf\u4e3b\u673a\u7684 ip \u5417      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>15<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2153274\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : csuzhangxc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4f20\u8fdb\u53bb\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153275\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ypcs03 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             aws ec2 \u53ef\u4ee5\u901a\u8fc7 IMDS, \u5176\u4ed6\u7684 cloud provider \u5e94\u8be5\u4e5f\u6709\u7c7b\u4f3c\u7684\u5427\u3002\u901a\u7528\u7684\u8c8c\u4f3c\u4e0d\u592a\u5bb9\u6613\uff0c\u8fd8\u8ddf\u5bb9\u5668\u7684 config \u6709\u5173\u6bd4\u5982&#8211;net=host.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153276\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : moonsn1994 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST<br \/>The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.<\/p>\n<p>The gateway is also reachable as gateway.docker.internal.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153277\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : moonsn1994 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             macos \u7684\u8bdd\uff0c\u5982\u4e0a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153278\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Latin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6302\u5bbf\u4e3b\u673a \/proc \u5230\u5bb9\u5668 \/host\/proc\uff0c<br \/>\u8fd0\u884c\u5bb9\u5668\u52a0 &#8211;privileged<br \/>nsenter &#8211;net=\/host\/proc\/1\/ns\/net ifconfig \u7f51\u5361\u540d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153279\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cheng6563 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u529e\u6cd5\uff0c\u811a\u672c\u91cc\u5148\u83b7\u5f97 IP \u518d\u542f\u52a8\u5bb9\u5668\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153280\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 0312birdzhang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1 \u52a0\u4e00\uff0c\u5176\u4ed6\u65b9\u6cd5\u4e0d\u63a8\u8350                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153281\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Ezez <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @moonsn1994 <br \/>@Latin <br \/>@0312birdzhang <br \/>\u8fd9\u4e09\u4e2a\u65b9\u6cd5\u6211\u76ee\u524d\u90fd\u67e5\u5230\u4e86\uff0c\u4f46\u662f\u73b0\u6709\u6761\u4ef6\u90fd\u4e0d\u652f\u6301\uff0c\u611f\u89c9\u8fd9\u4e2a\u529f\u80fd\u5b8c\u6210\u4e0d\u4e86\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153282\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jirajine <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/mageddo\/dns-proxy-server                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153283\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Ezez <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @cheng6563 \u90e8\u7f72\u8fd9\u4e00\u5757\u4e0d\u662f\u7531\u6211\u6765\u505a\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153284\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Ezez <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u7684\u76ee\u7684\u662f\u8981\u628a\u8fd9\u4e2a\u63d2\u4ef6\u80fd\u505a\u6210\u4e00\u4e2a\u901a\u7528\u7684\u63d2\u4ef6\uff0c\u67e5\u4e86\u4e00\u5708\uff0c\u611f\u89c9\u4e0d\u592a\u53ef\u80fd\uff0c\u6bd5\u7adf\u4e0d\u540c\u9879\u76ee\uff0c\u914d\u7f6e\u6216\u8005\u662f\u542f\u52a8\u65b9\u5f0f\u90fd\u4e0d\u4e00\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153285\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : q409640976 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             curl ip.sb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153286\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Smilencer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u7684\u505a\u6cd5\u662f\u5bb9\u5668\u542f\u52a8\u65f6\uff0c\u589e\u52a0 host\uff0c\u81ea\u52a8\u5c06\u5bbf\u4e3b\u673a docker \u7f51\u5173\u6620\u5c04\u5230 dockerhost<br \/>&#8220;`<br \/>docker run &#8211;add-host=dockerhost:`docker network inspect &#8211;format='{{range .IPAM.Config}}{{.Gateway}}{{end}}&#8217; bridge` <br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153287\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : holosola <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bd5\u8bd5\u7528 host.docker.internal                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2153288\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leschans <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             curl -s ip.sb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[\u6c42\u6559]\u5728 docker \u5bb9\u5668\u5185\u90e8&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\/125543"}],"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=125543"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/125543\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125543"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}