{"id":22,"date":"2026-03-13T11:01:22","date_gmt":"2026-03-13T11:01:22","guid":{"rendered":"https:\/\/www.yun.com.mp\/?p=22"},"modified":"2026-03-13T11:01:22","modified_gmt":"2026-03-13T11:01:22","slug":"wsl-2-%e4%bd%bf%e7%94%a8-docker-%e6%a1%a5%e6%8e%a5%e6%a8%a1%e5%bc%8f%e7%bd%91%e7%bb%9c%e8%ae%bf%e9%97%ae-https-%e8%b6%85%e6%97%b6%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.yun.com.mp\/?p=22","title":{"rendered":"WSL 2 \u4f7f\u7528 Docker \u6865\u63a5\u6a21\u5f0f\u7f51\u7edc\u8bbf\u95ee HTTPS \u8d85\u65f6\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"\n<p>WSL 2 \u4f7f\u7528 Docker \u6865\u63a5\u6a21\u5f0f\u7f51\u7edc\u8bbf\u95ee HTTPS \u8d85\u65f6\u7684\u89e3\u51b3\u65b9\u6cd5<\/p>\n\n\n\n<p>\u672c\u6587\u4ecb\u7ecd\u5728 WSL 2 \u4e2d\u4f7f\u7528 Docker \u7684\u6865\u63a5\u6a21\u5f0f\uff08bridge network\uff09\u8bbf\u95ee HTTPS \u65f6\u51fa\u73b0\u8d85\u65f6\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u6700\u8fd1\u4e00\u76f4\u5728 Windows \u4e0b\u4f7f\u7528\u57fa\u4e8e WSL 2 \u7684 Debian \u8fdb\u884c\u5f00\u53d1\u3002\u8bb8\u591a\u573a\u666f\u4e0b\u9700\u8981\u4f7f\u7528 Docker \u6784\u5efa\u955c\u50cf\uff0c\u4f46\u8fc7\u7a0b\u4e2d\u9047\u5230\u4e00\u4e2a\u5947\u602a\u7684\u95ee\u9898\uff0c\u5728 Docker \u5bb9\u5668\u5185\u90e8\u8bbf\u95ee HTTP \u7ad9\u70b9\u65f6\u4e00\u5207\u6b63\u5e38\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --rm curlimages\/curl time curl -s http:\/\/ip.gs\n192.0.2.2\nreal    0m 0.02s\nuser    0m 0.00s\nsys     0m 0.00s\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u4e00\u65e6\u5207\u6362\u4e3a HTTPS\uff0c\u8bbf\u95ee\u5c31\u4f1a\u660e\u663e\u53d8\u6162\uff0c\u5e76\u4e14\u6709\u4e00\u5b9a\u6982\u7387\u51fa\u73b0\u8d85\u65f6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --rm curlimages\/curl time curl -s https:\/\/ip.gs\n192.0.2.2\nreal    0m 6.52s\nuser    0m 0.00s\nsys     0m 0.00s\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u7136\u800c\uff0c\u5982\u679c\u5c06 Docker \u5207\u6362\u5230 Host \u6a21\u5f0f\uff08<code>--network=host<\/code>\uff09\uff0c\u8bbf\u95ee\u53c8\u6062\u590d\u6b63\u5e38\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --rm --network=host curlimages\/curl time curl -s https:\/\/ip.gs\n192.2.0.2\nreal    0m 0.28s\nuser    0m 0.00s\nsys     0m 0.00s\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u5728\u6392\u67e5\u4e86 WSL 2 \u7684 Debian \u7cfb\u7edf\u914d\u7f6e\u540e\uff0c\u6700\u7ec8\u8bf7\u6559 ChatGPT \u5f97\u5230\u7ed3\u8bba\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Path MTU \u4e0e\u9632\u706b\u5899\u6d41\u91cf\u68c0\u67e5\uff08inspection\uff09\u4e0d\u517c\u5bb9\u5bfc\u81f4\u95ee\u9898<\/p>\n<\/blockquote>\n<\/blockquote>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355\uff1a\u5c06 WSL 2 \u865a\u62df\u7f51\u7edc\u7684 MTU \u4e0b\u8c03\u4e3a&nbsp;<code>1400<\/code>&nbsp;\u5373\u53ef\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-tian-jia-docker-pei-zhi\">1\u3001\u6dfb\u52a0 Docker \u914d\u7f6e<\/h2>\n\n\n\n<p>\u5728 WSL 2 \u7684\u7cfb\u7edf\u91cc\uff0c\u4f7f\u7528 root \u7528\u6237\u4fee\u6539&nbsp;<code>\/etc\/docker\/daemon.json<\/code>&nbsp;\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"log-driver\": \"json-file\",\n    \"log-opts\": {\n        \"max-size\": \"20m\",\n        \"max-file\": \"3\"\n    },\n    \"mtu\": 1400,\n    \"dns\": &#91;\n      \"8.8.8.8\",\n      \"1.1.1.1\"\n    ]\n}\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u5176\u4e2d&nbsp;<code>\"mtu\": 1400,<\/code>&nbsp;\u662f\u5173\u952e\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u5728 Windows \u4e0b\u628a WSL 2 \u5173\u95ed\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl --shutdown\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-xiu-gai-wsl-2-wang-qia-pei-zhi\">2\u3001\u4fee\u6539 WSL 2 \u7f51\u5361\u914d\u7f6e<\/h2>\n\n\n\n<p>\u5728 Windows \u4e0b\u4f7f\u7528\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c Powershell\uff0c\u68c0\u67e5\u7f51\u5361\u540d\u79f0\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS C:\\Users\\showfom&gt; Get-NetAdapter | Where-Object { $_.Name -like \"*WSL*\" }\n\nName                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed\n----                      --------------------                    ------- ------       ----------             ---------\nvEthernet (WSL (Hyper-V \u2026 Hyper-V Virtual Ethernet Adapter #3          41 Up           12-34-56-78-AB-CD        10 Gbps\n\nPS C:\\Users\\showfom&gt; Get-NetAdapter | Format-Table -AutoSize\n\nName                               InterfaceDescription                      ifIndex Status       MacAddress        Lin\n                                                                                                                    kSp\n                                                                                                                    eed\n----                               --------------------                      ------- ------       ----------        ---\nvEthernet (Default Switch)         Hyper-V Virtual Ethernet Adapter               35 Up           12-34-56-78-AB-AB \u2026ps\nvEthernet (WSL (Hyper-V firewall)) Hyper-V Virtual Ethernet Adapter #3            41 Up           12-34-56-78-AB-CD \u2026ps\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u8f93\u51fa\u53ef\u4ee5\u770b\u5230\u5b8c\u6574\u540d\u79f0\u4e3a&nbsp;<code>vEthernet (WSL (Hyper-V firewall))<\/code>\uff0c\u7136\u540e\u4e3a\u5176\u8bbe\u7f6e MTU\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>netsh interface ipv4 set subinterface \"vEthernet (WSL (Hyper-V firewall))\" mtu=1400 store=persistent\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u51fa\u73b0&nbsp;<code>Ok.<\/code>&nbsp;\u5b57\u6837\u5373\u4ee3\u8868\u8bbe\u7f6e\u6210\u529f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-ce-shi-wsl-2-zhong-de-docker-wang-luo\">3\u3001\u6d4b\u8bd5 WSL 2 \u4e2d\u7684 Docker \u7f51\u7edc<\/h2>\n\n\n\n<p>\u7136\u540e\u91cd\u65b0\u8fd0\u884c WSL 2 \u865a\u62df\u673a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl -d debian\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u518d\u6b21\u6d4b\u8bd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --rm curlimages\/curl time curl -s https:\/\/ip.gs\n192.0.2.2\nreal    0m 0.28s\nuser    0m 0.00s\nsys     0m 0.00s\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<p>\u95ee\u9898\u5df2\u5b8c\u7f8e\u89e3\u51b3\uff0c\u53ef\u4ee5\u7ee7\u7eed\u6109\u5feb\u5730 Vibe Coding \u4e86\uff01&nbsp;<em>\u2605,\u00b0<\/em>:.\u2606(\uffe3\u25bd\uffe3)\/$:<em>.\u00b0\u2605<\/em>&nbsp;\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WSL 2 \u4f7f\u7528 Docker \u6865\u63a5\u6a21\u5f0f\u7f51\u7edc\u8bbf\u95ee HTTPS \u8d85\u65f6\u7684\u89e3\u51b3\u65b9\u6cd5 \u672c\u6587\u4ecb\u7ecd\u5728 WSL 2 \u4e2d\u4f7f\u7528 Docker \u7684\u6865\u63a5\u6a21\u5f0f\uff08bridge network\uff09\u8bbf\u95ee HTTPS \u65f6\u51fa\u73b0\u8d85\u65f6\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6cd5\u3002 \u6700\u8fd1\u4e00\u76f4\u5728 Windows \u4e0b\u4f7f\u7528\u57fa\u4e8e WSL 2 \u7684 Debian \u8fdb\u884c\u5f00\u53d1\u3002\u8bb8\u591a\u573a\u666f\u4e0b\u9700\u8981\u4f7f\u7528 Docker \u6784\u5efa\u955c\u50cf\uff0c\u4f46\u8fc7\u7a0b\u4e2d\u9047\u5230\u4e00\u4e2a\u5947\u602a\u7684\u95ee\u9898\uff0c\u5728 Docker \u5bb9\u5668\u5185\u90e8\u8bbf\u95ee HTTP \u7ad9\u70b9\u65f6\u4e00\u5207\u6b63\u5e38\uff1a Copy \u4e00\u65e6\u5207\u6362\u4e3a HTTPS\uff0c\u8bbf\u95ee\u5c31\u4f1a\u660e\u663e\u53d8\u6162\uff0c\u5e76\u4e14\u6709\u4e00\u5b9a\u6982\u7387\u51fa\u73b0\u8d85\u65f6\uff1a Copy \u7136\u800c\uff0c\u5982\u679c\u5c06 Docker \u5207\u6362\u5230 Host \u6a21\u5f0f\uff08&#8211;network=host\uff09\uff0c\u8bbf\u95ee\u53c8\u6062\u590d\u6b63\u5e38\uff1a Copy \u5728\u6392\u67e5\u4e86 WSL 2 \u7684 Debian \u7cfb\u7edf\u914d\u7f6e\u540e\uff0c\u6700\u7ec8\u8bf7\u6559 ChatGPT \u5f97\u5230\u7ed3\u8bba\uff1a \u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355\uff1a\u5c06 WSL 2 \u865a\u62df\u7f51\u7edc\u7684 MTU \u4e0b\u8c03\u4e3a&nbsp;1400&nbsp;\u5373\u53ef\u3002 1\u3001\u6dfb\u52a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":1,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions\/23"}],"wp:attachment":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}