{"id":7586,"date":"2024-11-14T11:11:23","date_gmt":"2024-11-14T03:11:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7586\/"},"modified":"2024-11-14T11:11:23","modified_gmt":"2024-11-14T03:11:23","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-windows-%e7%8e%af%e5%a2%83%e4%b8%8b%e4%bf%ae%e6%94%b9-docker-%e5%ae%b9%e5%99%a8%e5%8f%82%e6%95%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7586\/","title":{"rendered":"\u5982\u4f55\u5728 Windows \u73af\u5883\u4e0b\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173104276210134.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Windows \u73af\u5883\u4e0b\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5728 Windows \u73af\u5883\u4e0b\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u73af\u5883\u4e0b\u4fee\u6539  \u5bb9\u5668\u53c2\u6570<\/strong><\/p>\n<p>\u5728 windows \u73af\u5883\u4e2d\uff0c\u4e0e  \u73af\u5883\u4e0b\u4e0d\u540c\uff0c\u65e0\u6cd5\u76f4\u63a5\u4fee\u6539 docker \u5bb9\u5668\u7684\u53c2\u6570\u3002\u4ee5\u4e0b\u63d0\u4f9b\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528 environment \u53d8\u91cf<\/strong><\/p>\n<p>docker \u5bb9\u5668\u542f\u52a8\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u6765\u4fee\u6539\u67d0\u4e9b\u5bb9\u5668\u53c2\u6570\uff0c\u4f8b\u5982\u7aef\u53e3\u53f7\u548c\u5b57\u7b26\u7f16\u7801\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>docker run -e mysql_port=3306 -e mysql_character_set=utf8mb4 mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u521b\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf<\/strong><\/p>\n<p>\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u53c2\u6570\u4fee\u6539\uff0c\u4f8b\u5982 binlog \u4f4d\u7f6e\uff0c\u5219\u9700\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a dockerfile \u6587\u4ef6\uff0c\u5e76\u6307\u5b9a\u60f3\u8981\u4fee\u6539\u7684\u53c2\u6570\uff1a<\/li>\n<\/ol>\n<pre>from mysql\nenv mysql_port 3306\nenv mysql_character_set utf8mb4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u6784\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf\uff1a<\/li>\n<\/ol>\n<pre>docker build -t my-mysql .<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u4f7f\u7528\u81ea\u5b9a\u4e49\u955c\u50cf\u542f\u52a8\u5bb9\u5668\uff1a<\/li>\n<\/ol>\n<pre>docker run -p 3306:3306 my-mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728 windows \u73af\u5883\u4e2d\u7075\u6d3b\u5730\u4fee\u6539 docker \u5bb9\u5668\u53c2\u6570\uff0c\u4ece\u800c\u6ee1\u8db3\u4e0d\u540c\u7684\u5e94\u7528\u7a0b\u5e8f\u9700\u6c42\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728 Windows \u73af\u5883\u4e0b\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u4e0b\u4fee\u6539 \u5bb9\u5668\u53c2\u6570 \u5728 windows \u73af\u5883\u4e2d\uff0c\u4e0e \u73af\u5883\u4e0b\u4e0d\u540c\uff0c\u65e0\u6cd5\u76f4\u63a5\u4fee\u6539 docker \u5bb9\u5668\u7684\u53c2\u6570\u3002\u4ee5\u4e0b\u63d0\u4f9b\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a \u65b9\u6cd5 1\uff1a\u4f7f\u7528 environment \u53d8\u91cf docker \u5bb9\u5668\u542f\u52a8\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u6765\u4fee\u6539\u67d0\u4e9b\u5bb9\u5668\u53c2\u6570\uff0c\u4f8b\u5982\u7aef\u53e3\u53f7\u548c\u5b57\u7b26\u7f16\u7801\u3002\u5982\u4e0b\u6240\u793a\uff1a docker run -e mysql_port=3306 -e mysql_character_set=utf8mb4 mysql \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5 2\uff1a\u521b\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf \u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u53c2\u6570\u4fee\u6539\uff0c\u4f8b\u5982 binlog \u4f4d\u7f6e\uff0c\u5219\u9700\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a \u521b\u5efa\u4e00\u4e2a dockerfile \u6587\u4ef6\uff0c\u5e76\u6307\u5b9a\u60f3\u8981\u4fee\u6539\u7684\u53c2\u6570\uff1a from mysql env mysql_port 3306 env mysql_character_set utf8mb4 \u767b\u5f55\u540e\u590d\u5236 \u6784\u5efa\u81ea\u5b9a\u4e49\u955c\u50cf\uff1a docker build -t my-mysql . \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u81ea\u5b9a\u4e49\u955c\u50cf\u542f\u52a8\u5bb9\u5668\uff1a docker run -p 3306:3306 my-mysql \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728 windows [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7586","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7586"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7586\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}