{"id":421665,"date":"2024-11-30T03:26:24","date_gmt":"2024-11-29T19:26:24","guid":{"rendered":"https:\/\/www.idc.net\/help\/421665\/"},"modified":"2024-11-30T03:26:27","modified_gmt":"2024-11-29T19:26:27","slug":"docker%e4%b8%ad%e7%9a%84ipv6%e6%94%af%e6%8c%81%ef%bc%9a%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e5%b9%b6%e8%b0%83%e8%af%95ipv6%e7%bd%91%e7%bb%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/421665\/","title":{"rendered":"Docker\u4e2d\u7684IPv6\u652f\u6301\uff1a\u5982\u4f55\u914d\u7f6e\u5e76\u8c03\u8bd5IPv6\u7f51\u7edc\uff1f"},"content":{"rendered":"<h1 id=\"docker%e4%b8%ad%e7%9a%84ipv6%e6%94%af%e6%8c%81%ef%bc%9a%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e5%b9%b6%e8%b0%83%e8%af%95ipv6%e7%bd%91%e7%bb%9c%ef%bc%9f-zHKSpuLgVu\">Docker\u4e2d\u7684IPv6\u652f\u6301\uff1a\u5982\u4f55\u914d\u7f6e\u5e76\u8c03\u8bd5IPv6\u7f51\u7edc\uff1f<\/h1>\n<p>\u968f\u7740\u4e92\u8054\u7f51\u7684\u5feb\u901f\u53d1\u5c55\uff0cIPv4\u5730\u5740\u7684\u67af\u7aed\u95ee\u9898\u65e5\u76ca\u4e25\u91cd\uff0cIPv6\u4f5c\u4e3a\u4e0b\u4e00\u4ee3\u4e92\u8054\u7f51\u534f\u8bae\uff0c\u9010\u6e10\u6210\u4e3a\u7f51\u7edc\u53d1\u5c55\u7684\u8d8b\u52bf\u3002Docker\u4f5c\u4e3a\u4e00\u79cd\u6d41\u884c\u7684\u5bb9\u5668\u5316\u6280\u672f\uff0c\u652f\u6301IPv6\u7684\u914d\u7f6e\u548c\u4f7f\u7528\u3002\u672c\u6587\u5c06\u63a2\u8ba8\u5982\u4f55\u5728Docker\u4e2d\u914d\u7f6e\u548c\u8c03\u8bd5IPv6\u7f51\u7edc\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u5229\u7528\u8fd9\u4e00\u65b0\u5174\u6280\u672f\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afipv6%ef%bc%9f-zHKSpuLgVu\">\u4ec0\u4e48\u662fIPv6\uff1f<\/h2>\n<p>IPv6\uff08Internet Protocol version 6\uff09\u662f\u4e92\u8054\u7f51\u534f\u8bae\u7684\u7b2c\u516d\u7248\uff0c\u65e8\u5728\u89e3\u51b3IPv4\u5730\u5740\u4e0d\u8db3\u7684\u95ee\u9898\u3002IPv6\u5730\u5740\u957f\u5ea6\u4e3a128\u4f4d\uff0c\u80fd\u591f\u63d0\u4f9b\u51e0\u4e4e\u65e0\u9650\u7684\u5730\u5740\u7a7a\u95f4\u3002\u4e0eIPv4\u76f8\u6bd4\uff0cIPv6\u8fd8\u5f15\u5165\u4e86\u66f4\u597d\u7684\u8def\u7531\u6548\u7387\u548c\u5b89\u5168\u6027\u3002<\/p>\n<h2 id=\"docker%e4%b8%adipv6%e7%9a%84%e6%94%af%e6%8c%81-zHKSpuLgVu\">Docker\u4e2dIPv6\u7684\u652f\u6301<\/h2>\n<p>Docker\u4ece1.5\u7248\u672c\u5f00\u59cb\u652f\u6301IPv6\u3002\u901a\u8fc7\u542f\u7528IPv6\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u5bb9\u5668\u4e2d\u4f7f\u7528IPv6\u5730\u5740\u8fdb\u884c\u901a\u4fe1\uff0c\u8fd9\u5bf9\u4e8e\u9700\u8981\u652f\u6301\u73b0\u4ee3\u7f51\u7edc\u534f\u8bae\u7684\u5e94\u7528\u7a0b\u5e8f\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<h2 id=\"%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aedocker%e4%b8%ad%e7%9a%84ipv6-zHKSpuLgVu\">\u5982\u4f55\u914d\u7f6eDocker\u4e2d\u7684IPv6<\/h2>\n<p>\u8981\u5728Docker\u4e2d\u542f\u7528IPv6\uff0c\u60a8\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<h3 id=\"1-%e4%bf%ae%e6%94%b9docker%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-zHKSpuLgVu\">1. \u4fee\u6539Docker\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u7f16\u8f91Docker\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u901a\u5e38\uff0c\u8be5\u6587\u4ef6\u4f4d\u4e8e `\/etc\/docker\/daemon.json`\u3002\u5982\u679c\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u914d\u7f6e\uff1a<\/p>\n<pre><code>{\n  \"ipv6\": true,\n  \"fixed-cidr-v6\": \"2001:db8:1::\/64\"\n}<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u914d\u7f6e\u4e2d\uff0c`\"ipv6\": true` \u8868\u793a\u542f\u7528IPv6\uff0c`\"fixed-cidr-v6\"` \u6307\u5b9a\u4e86\u4e00\u4e2aIPv6\u5b50\u7f51\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8c03\u6574\u5b50\u7f51\u5730\u5740\u3002<\/p>\n<h3 id=\"2-%e9%87%8d%e5%90%afdocker%e6%9c%8d%e5%8a%a1-zHKSpuLgVu\">2. \u91cd\u542fDocker\u670d\u52a1<\/h3>\n<p>\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u60a8\u9700\u8981\u91cd\u542fDocker\u670d\u52a1\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo systemctl restart docker<\/code><\/pre>\n<h3 id=\"3-%e5%88%9b%e5%bb%ba%e6%94%af%e6%8c%81ipv6%e7%9a%84%e7%bd%91%e7%bb%9c-zHKSpuLgVu\">3. \u521b\u5efa\u652f\u6301IPv6\u7684\u7f51\u7edc<\/h3>\n<p>\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u652f\u6301IPv6\u7684Docker\u7f51\u7edc\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7f51\u7edc\uff1a<\/p>\n<pre><code>docker network create --ipv6 --subnet=2001:db8:1::\/64 my_ipv6_network<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u547d\u4ee4\u4e2d\uff0c`--ipv6` \u8868\u793a\u542f\u7528IPv6\uff0c`--subnet` \u6307\u5b9a\u4e86\u7f51\u7edc\u7684IPv6\u5b50\u7f51\u3002<\/p>\n<h3 id=\"4-%e5%90%af%e5%8a%a8%e5%ae%b9%e5%99%a8%e5%b9%b6%e8%bf%9e%e6%8e%a5%e5%88%b0ipv6%e7%bd%91%e7%bb%9c-zHKSpuLgVu\">4. \u542f\u52a8\u5bb9\u5668\u5e76\u8fde\u63a5\u5230IPv6\u7f51\u7edc<\/h3>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668\u5e76\u5c06\u5176\u8fde\u63a5\u5230\u521a\u521a\u521b\u5efa\u7684IPv6\u7f51\u7edc\uff1a<\/p>\n<pre><code>docker run -d --name my_container --network my_ipv6_network nginx<\/code><\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u542f\u52a8\u4e00\u4e2a\u540d\u4e3a `my_container` \u7684Nginx\u5bb9\u5668\uff0c\u5e76\u5c06\u5176\u8fde\u63a5\u5230 `my_ipv6_network` \u7f51\u7edc\u3002<\/p>\n<h2 id=\"%e8%b0%83%e8%af%95docker%e4%b8%ad%e7%9a%84ipv6%e7%bd%91%e7%bb%9c-zHKSpuLgVu\">\u8c03\u8bd5Docker\u4e2d\u7684IPv6\u7f51\u7edc<\/h2>\n<p>\u5728\u914d\u7f6e\u5b8cIPv6\u540e\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u8c03\u8bd5\u7f51\u7edc\u8fde\u63a5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u8c03\u8bd5\u5de5\u5177\u548c\u547d\u4ee4\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8ping%e5%91%bd%e4%bb%a4-zHKSpuLgVu\">1. \u4f7f\u7528ping\u547d\u4ee4<\/h3>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 `ping6` \u547d\u4ee4\u6d4b\u8bd5IPv6\u8fde\u63a5\uff1a<\/p>\n<pre><code>ping6 <\/code><\/pre>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8curl%e5%91%bd%e4%bb%a4-zHKSpuLgVu\">2. \u4f7f\u7528curl\u547d\u4ee4<\/h3>\n<p>\u4f7f\u7528 `curl` \u547d\u4ee4\u6d4b\u8bd5HTTP\u670d\u52a1\uff1a<\/p>\n<pre><code>curl -6 http:\/\/<\/code><\/pre>\n<h3 id=\"3-%e6%9f%a5%e7%9c%8b%e7%bd%91%e7%bb%9c%e9%85%8d%e7%bd%ae-zHKSpuLgVu\">3. \u67e5\u770b\u7f51\u7edc\u914d\u7f6e<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5bb9\u5668\u7684\u7f51\u7edc\u914d\u7f6e\uff1a<\/p>\n<pre><code>docker exec my_container ip -6 addr<\/code><\/pre>\n<p>\u8fd9\u5c06\u663e\u793a\u5bb9\u5668\u7684IPv6\u5730\u5740\u548c\u7f51\u7edc\u63a5\u53e3\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-zHKSpuLgVu\">\u603b\u7ed3<\/h2>\n<p>\u5728Docker\u4e2d\u914d\u7f6e\u548c\u8c03\u8bd5IPv6\u7f51\u7edc\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7\u4fee\u6539Docker\u914d\u7f6e\u6587\u4ef6\u3001\u521b\u5efa\u652f\u6301IPv6\u7684\u7f51\u7edc\u4ee5\u53ca\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u5229\u7528IPv6\u7684\u4f18\u52bf\u3002\u968f\u7740\u4e92\u8054\u7f51\u7684\u53d1\u5c55\uff0c\u638c\u63e1IPv6\u7684\u4f7f\u7528\u5c06\u4e3a\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u66f4\u597d\u7684\u517c\u5bb9\u6027\u548c\u6269\u5c55\u6027\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5bf9\u4e91\u670d\u52a1\u5668\u3001VPS\u6216\u5176\u4ed6\u76f8\u5173\u670d\u52a1\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u8bbf\u95ee\u6211\u4eec\u7684<a href=\"https:\/\/idc.net\">\u7f51\u7ad9<\/a>\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002\u540e\u6d6a\u4e91\u63d0\u4f9b\u591a\u79cd\u670d\u52a1\u5668\u89e3\u51b3\u65b9\u6848\uff0c\u5305\u62ec\u9999\u6e2f\u548c\u7f8e\u56fd\u7684\u670d\u52a1\u5668\uff0c\u6ee1\u8db3\u60a8\u7684\u4e0d\u540c\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728Docker\u4e2d\u914d\u7f6e\u548c\u8c03\u8bd5IPv6\u7f51\u7edc\uff0c\u786e\u4fdd\u5bb9\u5668\u95f4\u7684\u9ad8\u6548\u901a\u4fe1\u4e0e\u8fde\u63a5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[202757],"tags":[],"class_list":["post-421665","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/421665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=421665"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/421665\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=421665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=421665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=421665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}