{"id":16416,"date":"2026-05-25T16:21:50","date_gmt":"2026-05-25T08:21:50","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416"},"modified":"2026-05-25T16:23:43","modified_gmt":"2026-05-25T08:23:43","slug":"docker-%e9%87%8d%e8%a6%81%e6%a6%82%e5%bf%b5%e4%b9%8b-%e6%95%b0%e6%8d%ae%e5%8d%b7%ef%bc%88volume","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416","title":{"rendered":"Docker \u91cd\u8981\u6982\u5ff5\u4e4b- \u6570\u636e\u5377\uff08Volume)"},"content":{"rendered":"<p><strong>Docker \u6570\u636e\u5377\uff08Volume\uff09<\/strong> \u662f Docker \u4e2d\u7528\u4e8e\u5b9e\u73b0<strong>\u5bb9\u5668\u4e0e\u5bbf\u4e3b\u673a\u4e4b\u95f4\uff0c\u6216\u5bb9\u5668\u4e0e\u5bb9\u5668\u4e4b\u95f4\u5171\u4eab\u6570\u636e<\/strong>\u7684\u4e00\u79cd\u673a\u5236\u3002\u7b80\u5355\u7406\u89e3\uff0c\u5b83\u662f Docker \u5bb9\u5668\u4e2d\u4e00\u4e2a\u7279\u6b8a\u7684\u76ee\u5f55\u6216\u6587\u4ef6\uff0c\u53ef\u4ee5<strong>\u72ec\u7acb\u4e8e\u5bb9\u5668\u7684\u751f\u547d\u5468\u671f<\/strong>\u5b58\u5728\u3002<\/p>\n<p>\u4e3a\u4e86\u8ba9\u4f60\u66f4\u76f4\u89c2\u5730\u7406\u89e3\uff0c\u53ef\u4ee5\u770b\u51e0\u4e2a\u5173\u952e\u7279\u6027\uff1a<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416\/#1_%E5%AE%83%E8%A7%A3%E5%86%B3%E4%BA%86%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98%EF%BC%9F\" title=\"1. \u5b83\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898\uff1f\">1. \u5b83\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898\uff1f<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416\/#2_%E6%A0%B8%E5%BF%83%E7%89%B9%E7%82%B9\" title=\"2. \u6838\u5fc3\u7279\u70b9\">2. \u6838\u5fc3\u7279\u70b9<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416\/#3_%E4%B8%89%E7%A7%8D%E6%8C%82%E8%BD%BD%E6%96%B9%E5%BC%8F%E5%AF%B9%E6%AF%94%EF%BC%88%E5%B8%AE%E4%BD%A0%E6%9B%B4%E5%A5%BD%E5%8C%BA%E5%88%86%EF%BC%89\" title=\"3. \u4e09\u79cd\u6302\u8f7d\u65b9\u5f0f\u5bf9\u6bd4\uff08\u5e2e\u4f60\u66f4\u597d\u533a\u5206\uff09\">3. \u4e09\u79cd\u6302\u8f7d\u65b9\u5f0f\u5bf9\u6bd4\uff08\u5e2e\u4f60\u66f4\u597d\u533a\u5206\uff09<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416\/#4_%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%EF%BC%88%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B%EF%BC%89\" title=\"4. \u5e38\u7528\u64cd\u4f5c\uff08\u5feb\u901f\u4e0a\u624b\uff09\">4. \u5e38\u7528\u64cd\u4f5c\uff08\u5feb\u901f\u4e0a\u624b\uff09<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=16416\/#5_%E5%85%B8%E5%9E%8B%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF\" title=\"5. \u5178\u578b\u4f7f\u7528\u573a\u666f\">5. \u5178\u578b\u4f7f\u7528\u573a\u666f<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"1_%E5%AE%83%E8%A7%A3%E5%86%B3%E4%BA%86%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98%EF%BC%9F\"><\/span>1. \u5b83\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898\uff1f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>\u6570\u636e\u6301\u4e45\u5316<\/strong>\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5bb9\u5668\u5185\u521b\u5efa\u7684\u6587\u4ef6\u4f1a\u968f\u7740\u5bb9\u5668\u5220\u9664\u800c\u6d88\u5931\u3002\u6570\u636e\u5377\u8ba9\u6570\u636e\u5728\u5bb9\u5668\u5220\u9664\u540e\u4f9d\u7136\u4fdd\u7559\u5728\u5bbf\u4e3b\u673a\u4e0a\u3002<\/li>\n<li><strong>\u6570\u636e\u5171\u4eab<\/strong>\uff1a\u591a\u4e2a\u5bb9\u5668\u53ef\u4ee5\u6302\u8f7d\u540c\u4e00\u4e2a\u6570\u636e\u5377\uff0c\u5b9e\u73b0\u914d\u7f6e\u3001\u65e5\u5fd7\u6216\u4ee3\u7801\u7684\u5b9e\u65f6\u5171\u4eab\u3002<\/li>\n<li><strong>\u6027\u80fd\u4f18\u5316<\/strong>\uff1a\u7ed5\u8fc7\u5bb9\u5668\u7684\u5199\u65f6\u590d\u5236\uff08CoW\uff09\u673a\u5236\uff0c\u9002\u5408\u9ad8I\/O\u573a\u666f\uff08\u5982\u6570\u636e\u5e93\uff09\u3002<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"2_%E6%A0%B8%E5%BF%83%E7%89%B9%E7%82%B9\"><\/span>2. \u6838\u5fc3\u7279\u70b9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>\u72ec\u7acb\u751f\u547d\u5468\u671f<\/strong>\uff1a\u5220\u9664\u5bb9\u5668\u65f6\uff0c\u6570\u636e\u5377\u9ed8\u8ba4\u4e0d\u4f1a\u81ea\u52a8\u5220\u9664\uff08\u9664\u975e\u7528 <code>docker rm -v<\/code> \u6216 <code>docker volume prune<\/code> \u624b\u52a8\u6e05\u7406\uff09\u3002<\/li>\n<li><strong>\u53ef\u76f4\u63a5\u6302\u8f7d<\/strong>\uff1a\u5bbf\u4e3b\u673a\u4e0a\u6570\u636e\u5377\u7684\u5b58\u50a8\u4f4d\u7f6e\u7531 Docker \u7ba1\u7406\uff08\u901a\u5e38\u4f4d\u4e8e <code>\/var\/lib\/docker\/volumes\/<\/code>\uff09\uff0c\u65e0\u9700\u5173\u5fc3\u5177\u4f53\u8def\u5f84\u3002<\/li>\n<li><strong>\u652f\u6301\u9a71\u52a8\u63d2\u4ef6<\/strong>\uff1a\u53ef\u6302\u8f7d\u8fdc\u7a0b\u5b58\u50a8\uff08\u5982NFS\u3001Ceph\u3001\u4e91\u5382\u5546\u7684\u5757\u5b58\u50a8\uff09\u3002<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"3_%E4%B8%89%E7%A7%8D%E6%8C%82%E8%BD%BD%E6%96%B9%E5%BC%8F%E5%AF%B9%E6%AF%94%EF%BC%88%E5%B8%AE%E4%BD%A0%E6%9B%B4%E5%A5%BD%E5%8C%BA%E5%88%86%EF%BC%89\"><\/span>3. \u4e09\u79cd\u6302\u8f7d\u65b9\u5f0f\u5bf9\u6bd4\uff08\u5e2e\u4f60\u66f4\u597d\u533a\u5206\uff09<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u547d\u4ee4\u793a\u4f8b<\/th>\n<th style=\"text-align: left;\">\u7279\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>\u6570\u636e\u5377\uff08Volume\uff09<\/strong><\/td>\n<td style=\"text-align: left;\"><code>-v mydata:\/data<\/code><\/td>\n<td style=\"text-align: left;\">Docker\u7ba1\u7406\uff0c\u63a8\u8350\u7528\u4e8e\u6301\u4e45\u5316\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u7ed1\u5b9a\u6302\u8f7d\uff08Bind Mount\uff09<\/strong><\/td>\n<td style=\"text-align: left;\"><code>-v \/host\/path:\/container\/path<\/code><\/td>\n<td style=\"text-align: left;\">\u76f4\u63a5\u6620\u5c04\u5bbf\u4e3b\u673a\u4efb\u610f\u8def\u5f84\uff0c\u5e38\u7528\u4e8e\u5f00\u53d1\u8c03\u8bd5<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u4e34\u65f6\u6302\u8f7d\uff08tmpfs\uff09<\/strong><\/td>\n<td style=\"text-align: left;\"><code>--tmpfs \/tmp<\/code><\/td>\n<td style=\"text-align: left;\">\u4ec5\u5b58\u4e8e\u5185\u5b58\uff0c\u5bb9\u5668\u505c\u6b62\u540e\u6570\u636e\u6d88\u5931<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"4_%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%EF%BC%88%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B%EF%BC%89\"><\/span>4. \u5e38\u7528\u64cd\u4f5c\uff08\u5feb\u901f\u4e0a\u624b\uff09<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>bash<\/p>\n<pre><code># \u521b\u5efa\u6570\u636e\u5377\ndocker volume create my_volume\n\n# \u8fd0\u884c\u5bb9\u5668\u65f6\u6302\u8f7d\u5377\ndocker run -v my_volume:\/app\/data nginx\n\n# \u67e5\u770b\u6570\u636e\u5377\u5217\u8868\ndocker volume ls\n\n# \u67e5\u770b\u5377\u8be6\u60c5\uff08\u5305\u62ec\u5bbf\u4e3b\u673a\u5b9e\u9645\u8def\u5f84\uff09\ndocker volume inspect my_volume\n\n# \u5220\u9664\u672a\u4f7f\u7528\u7684\u5377\ndocker volume prune<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"5_%E5%85%B8%E5%9E%8B%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF\"><\/span>5. \u5178\u578b\u4f7f\u7528\u573a\u666f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>\u6570\u636e\u5e93\u5bb9\u5668<\/strong>\uff1a\u5982 MySQL\u3001PostgreSQL \u7684\u6570\u636e\u76ee\u5f55\u6302\u8f7d\u5230\u5377\uff0c\u9632\u6b62\u91cd\u542f\u4e22\u5931\u6570\u636e\u3002<\/li>\n<li><strong>\u914d\u7f6e\u6587\u4ef6\u7ba1\u7406<\/strong>\uff1a\u591a\u4e2a Nginx \u5bb9\u5668\u5171\u4eab\u540c\u4e00\u4e2a\u914d\u7f6e\u5377\u3002<\/li>\n<li><strong>\u65e5\u5fd7\u6536\u96c6<\/strong>\uff1a\u5e94\u7528\u5bb9\u5668\u5199\u65e5\u5fd7\u5230\u5377\uff0c\u53e6\u4e00\u4e2a\u65e5\u5fd7\u91c7\u96c6\u5bb9\u5668\u8bfb\u53d6\u8be5\u5377\u3002<\/li>\n<li><strong>\u5f00\u53d1\u70ed\u52a0\u8f7d<\/strong>\uff1a\u7ed1\u5b9a\u6302\u8f7d\u672c\u5730\u4ee3\u7801\u76ee\u5f55\u5230\u5bb9\u5668\u5185\uff0c\u4fee\u6539\u4ee3\u7801\u5373\u65f6\u751f\u6548\u3002<\/li>\n<\/ul>\n<p><strong>\u7b80\u5355\u603b\u7ed3<\/strong>\uff1a\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u201c\u968f\u8eabU\u76d8\u201d\u2014\u2014\u5bb9\u5668\u8fd0\u884c\u65f6\u53ef\u4ee5\u63d2\u4e0a\u7528\uff0c\u5bb9\u5668\u5220\u9664\u540eU\u76d8\u91cc\u7684\u6570\u636e\u4f9d\u7136\u5b58\u5728\uff0c\u8fd8\u53ef\u4ee5\u518d\u63d2\u5230\u5176\u4ed6\u5bb9\u5668\u4e0a\u4f7f\u7528\u3002<\/p>\n<button class=\"simplefavorite-button\" data-postid=\"16416\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>Docker \u6570\u636e\u5377\uff08Volume\uff09 \u662f Docker \u4e2d\u7528\u4e8e\u5b9e\u73b0\u5bb9\u5668\u4e0e\u5bbf\u4e3b\u673a\u4e4b\u95f4\uff0c\u6216\u5bb9\u5668\u4e0e\u5bb9\u5668\u4e4b\u95f4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[374],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/16416"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16416"}],"version-history":[{"count":1,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/16416\/revisions"}],"predecessor-version":[{"id":16417,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/16416\/revisions\/16417"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16416"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}