{"id":113830,"date":"2026-10-07T18:25:37","date_gmt":"2026-10-07T10:25:37","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/113830.html"},"modified":"2026-10-07T18:25:37","modified_gmt":"2026-10-07T10:25:37","slug":"docker%e9%95%9c%e5%83%8f%e5%88%86%e5%b1%82%e4%b8%8e%e5%8d%b7%e6%8c%82%e8%bd%bd%e5%ae%9e%e6%88%98%ef%bc%9a%e4%bb%8e%e5%ad%98%e5%82%a8%e5%8e%9f%e7%90%86%e5%88%b0%e6%95%b0%e6%8d%ae%e6%8c%81%e4%b9%85","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/113830.html","title":{"rendered":"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55"},"content":{"rendered":"<h3>\u4ece\u4e00\u4e2a\u6570\u636e\u4e22\u5931\u7684\u95ee\u9898\u8bf4\u8d77<\/h3>\n<p>\u524d\u6bb5\u65f6\u95f4\u5728\u505a\u4e00\u4e2aPython\u6570\u636e\u5904\u7406\u670d\u52a1&#xff0c;\u7528Docker\u8dd1\u4efb\u52a1\u3002\u670d\u52a1\u903b\u8f91\u5f88\u7b80\u5355&#xff1a;\u5bb9\u5668\u542f\u52a8\u540e\u4ece\u6d88\u606f\u961f\u5217\u62c9\u4efb\u52a1&#xff0c;\u628a\u4e2d\u95f4\u7ed3\u679c\u5199\u5230 \/app\/data \u76ee\u5f55&#xff0c;\u5904\u7406\u5b8c\u518d\u4e0a\u4f20\u3002\u672c\u5730\u5f00\u53d1\u65f6\u4e00\u5207\u6b63\u5e38&#xff0c;\u4f46\u90e8\u7f72\u5230\u6d4b\u8bd5\u73af\u5883\u540e&#xff0c;\u8fd0\u7ef4\u53cd\u9988\u8bf4\u5bb9\u5668\u91cd\u542f\u540e \/app\/data \u91cc\u7684\u6587\u4ef6\u5168\u6ca1\u4e86\u3002<\/p>\n<p>\u6211\u7b2c\u4e00\u53cd\u5e94\u662f\u4ee3\u7801\u91cc\u54ea\u91cc\u7684\u6e05\u7406\u903b\u8f91\u5199\u9519\u4e86&#xff0c;\u7ffb\u4e86\u4e00\u904d\u6ca1\u53d1\u73b0\u95ee\u9898\u3002\u540e\u6765\u624d\u610f\u8bc6\u5230&#xff0c;\/app\/data \u8fd9\u4e2a\u76ee\u5f55\u6839\u672c\u6ca1\u6709\u6302\u8f7d\u51fa\u6765&#xff0c;\u5b83\u5c31\u5728\u5bb9\u5668\u7684\u53ef\u5199\u5c42\u91cc\u3002\u5bb9\u5668\u4e00\u5220&#xff0c;\u53ef\u5199\u5c42\u8ddf\u7740\u6ca1&#xff0c;\u6570\u636e\u81ea\u7136\u5c31\u4e22\u4e86\u3002<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u672c\u8eab\u4e0d\u590d\u6742&#xff0c;\u4f46\u5b83\u7275\u626f\u51faDocker\u5b58\u50a8\u7684\u4e24\u4e2a\u6838\u5fc3\u6982\u5ff5&#xff1a;\u955c\u50cf\u5206\u5c42\u548c\u5377\u6302\u8f7d\u3002\u5f88\u591a\u521a\u63a5\u89e6Docker\u7684\u4eba&#xff08;\u5305\u62ec\u5f53\u65f6\u7684\u6211&#xff09;\u4f1a\u628a\u8fd9\u4e24\u4e2a\u4e1c\u897f\u6df7\u5728\u4e00\u8d77\u7406\u89e3&#xff0c;\u7ed3\u679c\u5728\u6570\u636e\u6301\u4e45\u5316\u3001\u955c\u50cf\u4f53\u79ef\u3001\u6784\u5efa\u7f13\u5b58\u8fd9\u4e9b\u5730\u65b9\u53cd\u590d\u8e29\u5751\u3002\u8fd9\u7bc7\u6587\u7ae0\u5c31\u628a\u8fd9\u4e24\u5757\u62c6\u5f00\u8bb2\u6e05\u695a&#xff0c;\u7ed3\u5408\u6211\u81ea\u5df1\u9a8c\u8bc1\u8fc7\u7684\u547d\u4ee4\u548c\u5b9e\u9645\u9879\u76ee\u91cc\u7684\u7528\u6cd5&#xff0c;\u5c3d\u91cf\u8bf4\u5f97\u5177\u4f53\u4e00\u4e9b\u3002<\/p>\n<h3>\u955c\u50cf\u5206\u5c42\u5230\u5e95\u662f\u600e\u4e48\u53e0\u52a0\u7684<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261007102528-6ac61e18509e7.png\" alt=\"\u955c\u50cf\u5206\u5c42\u5230\u5e95\u662f\u600e\u4e48\u53e0\u52a0\u7684\" \/><\/p>\n<p>\u5148\u8bf4\u955c\u50cf\u3002\u4e00\u4e2aDocker\u955c\u50cf\u4e0d\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5927\u6587\u4ef6&#xff0c;\u800c\u662f\u4e00\u5c42\u4e00\u5c42\u53e0\u8d77\u6765\u7684\u3002\u6bcf\u4e00\u5c42\u662f\u4e00\u4e2a\u53ea\u8bfb\u7684\u6587\u4ef6\u7cfb\u7edf\u5feb\u7167&#xff0c;\u5c42\u4e0e\u5c42\u4e4b\u95f4\u901a\u8fc7\u8054\u5408\u6587\u4ef6\u7cfb\u7edf&#xff08;Union File System&#xff09;\u7ec4\u5408\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u6839\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n<p>\u5728Linux\u4e0a&#xff0c;Docker\u9ed8\u8ba4\u7528\u7684\u5b58\u50a8\u9a71\u52a8\u901a\u5e38\u662f overlay2\u3002\u53ef\u4ee5\u8fd9\u6837\u786e\u8ba4\u5f53\u524d\u73af\u5883&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> info <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> <span class=\"token string\">&#034;Storage Driver&#034;<\/span><\/p>\n<p>\u6211\u672c\u673a\u8f93\u51fa\u662f Storage Driver: overlay2&#xff0c;\u8fd9\u662f\u76ee\u524d\u4e3b\u6d41Linux\u53d1\u884c\u7248\u4e0a\u7684\u9ed8\u8ba4\u503c\u3002\u5982\u679c\u4f60\u5728macOS\u6216Windows\u4e0a\u7528Docker Desktop&#xff0c;\u5e95\u5c42\u5176\u5b9e\u662f\u5728\u4e00\u4e2aLinux\u865a\u62df\u673a\u91cc\u8dd1&#xff0c;\u9a71\u52a8\u540c\u6837\u662foverlay2\u3002<\/p>\n<h4>\u5206\u5c42\u662f\u600e\u4e48\u4ea7\u751f\u7684<\/h4>\n<p>\u6bcf\u4e2a RUN\u3001COPY\u3001ADD \u6307\u4ee4\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u65b0\u5c42\u3002\u770b\u4e00\u4e2a\u7b80\u5355\u7684Dockerfile&#xff1a;<\/p>\n<p>FROM python:3.11-slim<br \/>\nWORKDIR \/app<br \/>\nCOPY requirements.txt .<br \/>\nRUN pip install &#8211;no-cache-dir -r requirements.txt<br \/>\nCOPY . .<br \/>\nCMD [&#034;python&#034;, &#034;main.py&#034;]<\/p>\n<p>\u6784\u5efa\u5b8c\u4e4b\u540e\u7528 docker history \u80fd\u770b\u5230\u6bcf\u4e00\u5c42\u7684\u6765\u6e90\u548c\u5927\u5c0f&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> <span class=\"token function\">history<\/span> myapp:latest<\/p>\n<p>\u8f93\u51fa\u91cc\u4f1a\u5217\u51fa\u6bcf\u4e00\u5c42\u5bf9\u5e94\u7684\u6307\u4ee4\u3001\u521b\u5efa\u65f6\u95f4\u3001\u5927\u5c0f\u3002pip install \u90a3\u4e00\u5c42\u901a\u5e38\u6700\u5927&#xff0c;\u56e0\u4e3a\u88c5\u7684\u5305\u90fd\u5728\u8fd9\u5c42\u3002COPY . . \u90a3\u5c42\u53ea\u5305\u542b\u4ee3\u7801\u53d8\u66f4\u90e8\u5206\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u4e2a\u5bb9\u6613\u5ffd\u7565\u7684\u70b9&#xff1a;\u6bcf\u4e00\u5c42\u53ea\u8bb0\u5f55\u76f8\u5bf9\u4e8e\u4e0a\u4e00\u5c42\u7684\u5dee\u5f02\u3002\u6bd4\u5982\u7b2c\u4e00\u5c42\u88c5\u4e86requests&#xff0c;\u7b2c\u4e8c\u5c42\u53c8\u88c5\u4e86flask&#xff0c;\u7b2c\u4e8c\u5c42\u4e0d\u4f1a\u91cd\u590d\u8bb0\u5f55requests&#xff0c;\u53ea\u8bb0\u5f55flask\u76f8\u5173\u7684\u6587\u4ef6\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u591a\u4e2a\u955c\u50cf\u5171\u4eab\u57fa\u7840\u5c42\u65f6&#xff0c;\u78c1\u76d8\u5360\u7528\u4e0d\u4f1a\u7ebf\u6027\u589e\u957f\u3002<\/p>\n<h4>\u53ef\u5199\u5c42&#xff1a;\u5bb9\u5668\u81ea\u5df1\u7684\u90a3\u5c42<\/h4>\n<p>\u955c\u50cf\u7684\u6240\u6709\u5c42\u90fd\u662f\u53ea\u8bfb\u7684\u3002\u5bb9\u5668\u542f\u52a8\u65f6&#xff0c;Docker\u4f1a\u5728\u955c\u50cf\u6700\u4e0a\u9762\u518d\u52a0\u4e00\u4e2a\u53ef\u5199\u5c42&#xff08;\u4e5f\u53eb\u5bb9\u5668\u5c42&#xff09;\u3002\u6240\u6709\u5bf9\u5bb9\u5668\u7684\u5199\u64cd\u4f5c\u2014\u2014\u6539\u6587\u4ef6\u3001\u5efa\u76ee\u5f55\u3001\u5220\u4e1c\u897f\u2014\u2014\u90fd\u53d1\u751f\u5728\u8fd9\u4e00\u5c42\u3002<\/p>\n<p>\u5173\u952e\u673a\u5236\u5728\u8fd9\u91cc&#xff1a;\u5f53\u5bb9\u5668\u8981\u4fee\u6539\u4e00\u4e2a\u5b58\u5728\u4e8e\u955c\u50cf\u5c42\u91cc\u7684\u6587\u4ef6\u65f6&#xff0c;overlay2\u4f1a\u5148\u628a\u90a3\u4e2a\u6587\u4ef6\u4ece\u53ea\u8bfb\u5c42\u590d\u5236\u5230\u53ef\u5199\u5c42&#xff0c;\u7136\u540e\u518d\u6539\u3002\u8fd9\u4e2a\u64cd\u4f5c\u53ebcopy-on-write&#xff08;\u5199\u65f6\u590d\u5236&#xff09;\u3002\u8bfb\u64cd\u4f5c\u4e0d\u53d7\u5f71\u54cd&#xff0c;\u76f4\u63a5\u8bfb\u53ea\u8bfb\u5c42\u3002<\/p>\n<p>\u7528\u4e2a\u5177\u4f53\u4f8b\u5b50\u9a8c\u8bc1\u4e00\u4e0b\u3002\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668&#xff0c;\u5f80 \/app \u5199\u4e2a\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-it<\/span> <span class=\"token parameter variable\">&#8211;name<\/span> test-layer python:3.11-slim <span class=\"token function\">bash<\/span><br \/>\n<span class=\"token comment\"># \u5bb9\u5668\u5185\u6267\u884c<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;hello&#034;<\/span> <span class=\"token operator\">&gt;<\/span> \/app\/test.txt<\/p>\n<p>\u8fd9\u65f6\u5019 \/app\/test.txt \u53ea\u5b58\u5728\u4e8e\u53ef\u5199\u5c42\u3002\u9000\u51fa\u5bb9\u5668&#xff08;\u4e0d\u5220&#xff09;&#xff0c;\u91cd\u65b0 docker start \u8fdb\u53bb&#xff0c;\u6587\u4ef6\u8fd8\u5728&#xff0c;\u56e0\u4e3a\u53ef\u5199\u5c42\u8fd8\u5728\u3002\u4f46\u53ea\u8981 docker rm \u6389\u5bb9\u5668&#xff0c;\u53ef\u5199\u5c42\u9500\u6bc1&#xff0c;\u6587\u4ef6\u5c31\u6ca1\u4e86\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u6587\u7ae0\u5f00\u5934\u90a3\u4e2a\u95ee\u9898\u7684\u6839\u56e0&#xff1a;\u53ef\u5199\u5c42\u8ddf\u7740\u5bb9\u5668\u751f\u547d\u5468\u671f\u8d70&#xff0c;\u5bb9\u5668\u5220\u4e86\u6570\u636e\u5c31\u6ca1\u4e86\u3002<\/p>\n<p>\u3010\u5173\u952e\u7ed3\u8bba\u3011\u955c\u50cf\u5c42\u53ea\u8bfb\u4e14\u53ef\u5171\u4eab&#xff0c;\u5bb9\u5668\u53ef\u5199\u5c42\u72ec\u4eab\u4e14\u968f\u5bb9\u5668\u9500\u6bc1\u3002\u9700\u8981\u8de8\u5bb9\u5668\u751f\u547d\u5468\u671f\u4fdd\u7559\u7684\u6570\u636e&#xff0c;\u5fc5\u987b\u653e\u5230\u5377\u91cc\u3002<\/p>\n<h3>\u5377\u6302\u8f7d&#xff1a;\u628a\u6570\u636e\u4ece\u53ef\u5199\u5c42\u91cc&#034;\u635e&#034;\u51fa\u6765<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261007102528-6ac61e18a272e.png\" alt=\"\u5377\u6302\u8f7d\uff1a\u628a\u6570\u636e\u4ece\u53ef\u5199\u5c42\u91cc&quot;\u635e&quot;\u51fa\u6765\" \/><\/p>\n<p>\u5377&#xff08;Volume&#xff09;\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u72ec\u7acb\u4e8e\u5bb9\u5668\u53ef\u5199\u5c42\u7684\u5b58\u50a8\u4f4d\u7f6e&#xff0c;\u6302\u8f7d\u5230\u5bb9\u5668\u7684\u67d0\u4e2a\u8def\u5f84\u4e0a\u3002\u5bf9\u5bb9\u5668\u6765\u8bf4&#xff0c;\u5f80\u6302\u8f7d\u70b9\u5199\u6570\u636e&#xff0c;\u5b9e\u9645\u5199\u5230\u7684\u662f\u5bbf\u4e3b\u673a\u4e0a\u7684\u67d0\u4e2a\u76ee\u5f55&#xff0c;\u800c\u4e0d\u662f\u53ef\u5199\u5c42\u3002<\/p>\n<p>Docker\u91cc\u4e3b\u8981\u6709\u4e09\u79cd\u6302\u8f7d\u65b9\u5f0f&#xff1a;<\/p>\n<table>\n<tr>\u65b9\u6848\u4f18\u70b9\u7f3a\u70b9\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>bind mount<\/td>\n<td>\u76f4\u63a5\u6620\u5c04\u5bbf\u4e3b\u673a\u8def\u5f84&#xff0c;\u65b9\u4fbf\u67e5\u770b\u548c\u7f16\u8f91<\/td>\n<td>\u4f9d\u8d56\u5bbf\u4e3b\u673a\u76ee\u5f55\u7ed3\u6784&#xff0c;\u8de8\u5e73\u53f0\u4e00\u81f4\u6027\u5dee<\/td>\n<td>\u5f00\u53d1\u73af\u5883\u4ee3\u7801\u540c\u6b65\u3001\u914d\u7f6e\u6587\u4ef6\u6ce8\u5165<\/td>\n<\/tr>\n<tr>\n<td>named volume<\/td>\n<td>Docker\u7ba1\u7406&#xff0c;\u8de8\u5e73\u53f0\u4e00\u81f4&#xff0c;\u6027\u80fd\u597d<\/td>\n<td>\u4f4d\u7f6e\u4e0d\u76f4\u89c2&#xff0c;\u9700\u7528docker volume\u547d\u4ee4\u67e5\u770b<\/td>\n<td>\u6570\u636e\u5e93\u6570\u636e\u3001\u751f\u4ea7\u73af\u5883\u6301\u4e45\u5316<\/td>\n<\/tr>\n<tr>\n<td>tmpfs mount<\/td>\n<td>\u5185\u5b58\u5b58\u50a8&#xff0c;\u8bfb\u5199\u5feb<\/td>\n<td>\u5bb9\u5668\u505c\u6b62\u5373\u4e22\u5931&#xff0c;\u5360\u5185\u5b58<\/td>\n<td>\u4e34\u65f6\u7f13\u5b58\u3001\u654f\u611f\u6570\u636e\u4e0d\u7559\u76d8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>bind mount\u7684\u5b9e\u9645\u7528\u6cd5<\/h4>\n<p>bind mount\u6700\u76f4\u63a5\u7684\u5199\u6cd5\u662f -v \u52a0\u4e0a\u5bbf\u4e3b\u673a\u7edd\u5bf9\u8def\u5f84&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">&#8211;name<\/span> myapp <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-v<\/span> \/home\/user\/appdata:\/app\/data <span class=\"token punctuation\">\\\\<\/span><br \/>\n  myapp:latest<\/p>\n<p>\u8fd9\u6837 \/app\/data \u91cc\u7684\u5185\u5bb9\u5b9e\u9645\u5b58\u5728\u5bbf\u4e3b\u673a\u7684 \/home\/user\/appdata\u3002\u5bb9\u5668\u5220\u4e86&#xff0c;\u6570\u636e\u8fd8\u5728\u3002<\/p>\n<p>\u5f00\u53d1\u65f6\u7ecf\u5e38\u7528\u8fd9\u79cd\u65b9\u5f0f\u628a\u4ee3\u7801\u76ee\u5f55\u6302\u8fdb\u53bb&#xff0c;\u6539\u5b8c\u4ee3\u7801\u4e0d\u7528\u91cd\u65b0\u6784\u5efa\u955c\u50cf&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-v<\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token builtin class-name\">pwd<\/span><span class=\"token variable\">)<\/span><\/span>\/src:\/app\/src <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">8000<\/span>:8000 <span class=\"token punctuation\">\\\\<\/span><br \/>\n  myapp:latest<\/p>\n<h4>named volume\u7684\u7528\u6cd5<\/h4>\n<p>named volume\u4e0d\u7528\u6307\u5b9a\u5bbf\u4e3b\u673a\u8def\u5f84&#xff0c;Docker\u81ea\u5df1\u7ba1\u7406&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> volume create appdata<br \/>\n<span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">&#8211;name<\/span> myapp <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-v<\/span> appdata:\/app\/data <span class=\"token punctuation\">\\\\<\/span><br \/>\n  myapp:latest<\/p>\n<p>\u60f3\u77e5\u9053\u6570\u636e\u5b9e\u9645\u5b58\u5728\u54ea&#xff0c;\u53ef\u4ee5\u67e5&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> volume inspect appdata<\/p>\n<p>\u8f93\u51fa\u91cc\u7684 Mountpoint \u5b57\u6bb5\u5c31\u662f\u5bbf\u4e3b\u673a\u4e0a\u7684\u5b9e\u9645\u8def\u5f84&#xff0c;\u4e00\u822c\u5728 \/var\/lib\/docker\/volumes\/ \u4e0b\u9762\u3002<\/p>\n<h4>\u4e00\u4e2a\u5bb9\u6613\u641e\u6df7\u7684\u7ec6\u8282&#xff1a;\u533f\u540d\u5377<\/h4>\n<p>\u5982\u679c\u53ea\u5199\u5bb9\u5668\u8def\u5f84\u4e0d\u5199\u6765\u6e90&#xff0c;\u6bd4\u5982 -v \/app\/data&#xff0c;Docker\u4f1a\u521b\u5efa\u4e00\u4e2a\u533f\u540d\u5377\u3002\u7528 docker volume ls \u80fd\u770b\u5230\u4e00\u5806\u54c8\u5e0c\u547d\u540d\u7684\u5377\u3002\u8fd9\u4e9b\u5377\u5728\u5bb9\u5668\u5220\u9664\u65f6\u9ed8\u8ba4\u4e0d\u4f1a\u81ea\u52a8\u6e05\u7406&#xff08;\u9664\u975e\u7528 &#8211;rm \u6216\u8005\u624b\u52a8 docker volume prune&#xff09;&#xff0c;\u65f6\u95f4\u957f\u4e86\u4f1a\u5360\u4e0d\u5c11\u78c1\u76d8\u3002<\/p>\n<p>\u6211\u4e2a\u4eba\u4e60\u60ef\u662f&#xff1a;\u751f\u4ea7\u73af\u5883\u7528named volume&#xff0c;\u5f00\u53d1\u73af\u5883\u7528bind mount&#xff0c;\u5c3d\u91cf\u4e0d\u7528\u533f\u540d\u5377\u3002<\/p>\n<h3>\u6302\u8f7d\u8986\u76d6&#xff1a;\u4e3a\u4ec0\u4e48\u6211\u7684\u955c\u50cf\u6587\u4ef6\u4e0d\u89c1\u4e86<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261007102532-6ac61e1c8d3ec.png\" alt=\"\u6302\u8f7d\u8986\u76d6\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u955c\u50cf\u6587\u4ef6\u4e0d\u89c1\u4e86\" \/><\/p>\n<p>\u8fd9\u662f\u6211\u81ea\u5df1\u8e29\u8fc7\u7684\u4e00\u4e2a\u5751\u3002\u6709\u4e2a\u955c\u50cf\u5728\u6784\u5efa\u65f6\u5f80 \/app\/config \u653e\u4e86\u4e00\u4efd\u9ed8\u8ba4\u914d\u7f6e&#xff1a;<\/p>\n<p>COPY config\/default.yaml \/app\/config\/default.yaml<\/p>\n<p>\u8fd0\u884c\u65f6\u60f3\u7528\u5bbf\u4e3b\u673a\u7684\u914d\u7f6e\u8986\u76d6&#xff0c;\u5c31\u8fd9\u4e48\u6302&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-v<\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token builtin class-name\">pwd<\/span><span class=\"token variable\">)<\/span><\/span>\/myconfig:\/app\/config myapp:latest<\/p>\n<p>\u7ed3\u679c\u5bb9\u5668\u91cc \/app\/config \u53ea\u5269 myconfig \u76ee\u5f55\u91cc\u7684\u4e1c\u897f&#xff0c;default.yaml \u4e0d\u89c1\u4e86\u3002<\/p>\n<p>\u539f\u56e0\u662f&#xff1a;\u6302\u8f7d\u4f1a\u8986\u76d6\u76ee\u6807\u8def\u5f84\u7684\u539f\u6709\u5185\u5bb9\u3002bind mount\u548cnamed volume\u90fd\u4e00\u6837\u3002\u6302\u8f7d\u70b9\u4e0b\u9762\u539f\u672c\u955c\u50cf\u5c42\u91cc\u7684\u6587\u4ef6&#xff0c;\u4f1a\u88ab\u6302\u8f7d\u6e90\u7684\u5185\u5bb9\u5b8c\u5168\u906e\u4f4f\u3002<\/p>\n<p>\u8fd9\u4e00\u70b9\u548c\u5f88\u591a\u4eba\u76f4\u89c9\u76f8\u53cd\u3002\u76f4\u89c9\u4e0a\u89c9\u5f97&#034;\u6302\u8f7d\u662f\u53e0\u52a0&#034;&#xff0c;\u5b9e\u9645\u662f&#034;\u66ff\u6362&#034;\u3002<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\u6709\u51e0\u79cd&#xff1a;<\/p>\n<li>\u6302\u8f7d\u5230\u4e0d\u540c\u7684\u8def\u5f84&#xff0c;\u4ee3\u7801\u91cc\u505a\u914d\u7f6e\u5408\u5e76<\/li>\n<li>\u7528 docker cp \u5148\u628a\u9ed8\u8ba4\u914d\u7f6e\u62f7\u51fa\u6765&#xff0c;\u518d\u6302\u8f7d<\/li>\n<li>\u6784\u5efa\u65f6\u5c31\u4e0d\u653e\u9ed8\u8ba4\u914d\u7f6e&#xff0c;\u5b8c\u5168\u4f9d\u8d56\u6302\u8f7d<\/li>\n<p>\u6211\u73b0\u5728\u7684\u505a\u6cd5\u662f\u914d\u7f6e\u76ee\u5f55\u4e0d\u9884\u5148\u653e\u6587\u4ef6&#xff0c;\u955c\u50cf\u53ea\u63d0\u4f9b\u4e00\u4efd\u793a\u4f8b\u914d\u7f6e\u653e\u5728\u522b\u7684\u4f4d\u7f6e&#xff08;\u6bd4\u5982 \/app\/config.example&#xff09;&#xff0c;\u8fd0\u884c\u65f6\u7531\u542f\u52a8\u811a\u672c\u5224\u65ad&#xff1a;\u5982\u679c\u6302\u8f7d\u76ee\u5f55\u4e3a\u7a7a&#xff0c;\u5c31\u628a\u793a\u4f8b\u62f7\u8fc7\u53bb\u3002<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/sh<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token parameter variable\">-z<\/span> <span class=\"token string\">&#034;<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">ls<\/span> <span class=\"token parameter variable\">-A<\/span> \/app\/config<span class=\"token variable\">)<\/span><\/span>&#034;<\/span> <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n  <span class=\"token function\">cp<\/span> \/app\/config.example\/* \/app\/config\/<br \/>\n<span class=\"token keyword\">fi<\/span><br \/>\n<span class=\"token builtin class-name\">exec<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$&#064;<\/span>&#034;<\/span><\/p>\n<p>\u3010\u8e29\u5751\u63d0\u9192\u3011\u6302\u8f7d\u662f\u8986\u76d6\u4e0d\u662f\u53e0\u52a0\u3002\u6302\u8f7d\u70b9\u4e0b\u9762\u7684\u955c\u50cf\u5185\u5bb9\u4f1a\u88ab\u5b8c\u5168\u906e\u4f4f&#xff0c;\u4e0d\u662f\u5408\u5e76\u3002<\/p>\n<h3>\u6302\u8f7d\u8def\u5f84\u7684\u6743\u9650\u95ee\u9898<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261007102532-6ac61e1cba8a9.png\" alt=\"\u6302\u8f7d\u8def\u5f84\u7684\u6743\u9650\u95ee\u9898\" \/><\/p>\n<p>\u53e6\u4e00\u4e2a\u5b9e\u9645\u9047\u5230\u8fc7\u7684\u95ee\u9898\u662f\u6743\u9650\u3002\u7528bind mount\u6302\u5bbf\u4e3b\u673a\u76ee\u5f55\u65f6&#xff0c;\u5bb9\u5668\u5185\u8fdb\u7a0b\u7684\u7528\u6237ID\u548c\u5bbf\u4e3b\u673a\u76ee\u5f55\u7684\u5c5e\u4e3b\u5982\u679c\u4e0d\u4e00\u81f4&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u5199\u4e0d\u8fdb\u53bb\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u6bd4\u5982\u5bb9\u5668\u91cc\u7528\u975eroot\u7528\u6237\u8dd1&#xff08;\u8fd9\u662f\u597d\u4e60\u60ef&#xff09;&#xff0c;UID\u662f1000&#xff0c;\u4f46\u5bbf\u4e3b\u673a\u4e0a\u6302\u8f7d\u7684\u76ee\u5f55\u5c5e\u4e3b\u662froot&#xff0c;\u6743\u9650755\u3002\u5bb9\u5668\u91cc\u4e00\u5199\u5c31\u62a5Permission denied\u3002<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u6ca1\u6709\u4e00\u52b3\u6c38\u9038\u7684\u89e3\u6cd5&#xff0c;\u5e38\u89c1\u5904\u7406\u65b9\u5f0f&#xff1a;<\/p>\n<li>\u6784\u5efa\u955c\u50cf\u65f6\u521b\u5efa\u548c\u5bbf\u4e3b\u673a\u4e00\u81f4UID\u7684\u7528\u6237<\/li>\n<li>\u542f\u52a8\u65f6\u7528 -u $(id -u):$(id -g) \u6307\u5b9a\u7528\u6237<\/li>\n<li>\u5bbf\u4e3b\u673a\u4e0a\u8c03\u6574\u76ee\u5f55\u6743\u9650<\/li>\n<p>\u6211\u4e00\u822c\u5728Dockerfile\u91cc\u663e\u5f0f\u6307\u5b9aUID&#xff1a;<\/p>\n<p>FROM python:3.11-slim<br \/>\nRUN useradd -m -u 1000 appuser<br \/>\nWORKDIR \/app<br \/>\nCOPY &#8211;chown&#061;appuser:appuser . .<br \/>\nUSER appuser<\/p>\n<p>\u7136\u540e\u786e\u4fdd\u5bbf\u4e3b\u673a\u4e0a\u6302\u8f7d\u7684\u76ee\u5f55\u5c5e\u4e3b\u4e5f\u662fUID 1000&#xff0c;\u6216\u8005\u7528 chown \u8c03\u6574\u4e00\u4e0b\u3002<\/p>\n<p>named volume\u5c31\u6ca1\u8fd9\u4e2a\u95ee\u9898&#xff0c;\u56e0\u4e3aDocker\u521b\u5efa\u5377\u65f6\u4f1a\u5904\u7406\u6743\u9650\u3002\u8fd9\u4e5f\u662f\u751f\u4ea7\u73af\u5883\u6211\u66f4\u503e\u5411\u7528named volume\u7684\u539f\u56e0\u4e4b\u4e00\u3002<\/p>\n<h3>\u955c\u50cf\u4f53\u79ef\u4f18\u5316&#xff1a;\u5206\u5c42\u5e26\u6765\u7684\u8fde\u9501\u53cd\u5e94<\/h3>\n<p>\u7406\u89e3\u4e86\u5206\u5c42&#xff0c;\u955c\u50cf\u4f53\u79ef\u4f18\u5316\u5c31\u6709\u65b9\u5411\u4e86\u3002\u56e0\u4e3a\u6bcf\u5c42\u53ea\u8bb0\u5f55\u5dee\u5f02&#xff0c;\u6240\u4ee5&#xff1a;<\/p>\n<p>\u628a\u4e0d\u5e38\u53d8\u7684\u5185\u5bb9\u653e\u524d\u9762&#xff0c;\u5e38\u53d8\u7684\u653e\u540e\u9762\u3002 \u8fd9\u6837\u6784\u5efa\u65f6\u80fd\u590d\u7528\u7f13\u5b58&#xff0c;\u4e5f\u907f\u514d\u6bcf\u6b21\u6539\u52a8\u90fd\u91cd\u88c5\u4f9d\u8d56\u3002<\/p>\n<p>\u4e00\u4e2a\u53cd\u4f8b&#xff1a;<\/p>\n<p>FROM python:3.11-slim<br \/>\nWORKDIR \/app<br \/>\nCOPY . .<br \/>\nRUN pip install -r requirements.txt<\/p>\n<p>\u6bcf\u6b21\u6539\u4e00\u884c\u4ee3\u7801&#xff0c;COPY . . \u8fd9\u5c42\u5c31\u53d8\u4e86&#xff0c;\u540e\u9762 pip install \u7684\u7f13\u5b58\u4e5f\u5931\u6548&#xff0c;\u6bcf\u6b21\u90fd\u8981\u91cd\u88c5\u4f9d\u8d56\u3002\u6539\u6210\u5148\u62f7requirements\u518d\u88c5\u5305&#xff0c;\u7f13\u5b58\u5c31\u80fd\u590d\u7528&#xff1a;<\/p>\n<p>FROM python:3.11-slim<br \/>\nWORKDIR \/app<br \/>\nCOPY requirements.txt .<br \/>\nRUN pip install &#8211;no-cache-dir -r requirements.txt<br \/>\nCOPY . .<\/p>\n<p>\u53e6\u5916&#xff0c;RUN \u91cc\u4e34\u65f6\u4e0b\u8f7d\u7684\u6587\u4ef6\u5982\u679c\u5728\u540c\u4e00\u5c42\u91cc\u5220\u6389&#xff0c;\u5176\u5b9e\u4e0d\u51cf\u5c0f\u4f53\u79ef&#xff0c;\u56e0\u4e3a\u90a3\u4e00\u5c42\u7684\u5dee\u5f02\u8bb0\u5f55\u91cc\u5305\u542b\u4e86&#034;\u4e0b\u8f7d&#034;\u548c&#034;\u5220\u9664&#034;\u4e24\u4e2a\u52a8\u4f5c\u3002\u8981\u51cf\u5c0f\u4f53\u79ef\u5f97\u5408\u5e76\u5230\u4e00\u6761 RUN \u91cc&#xff0c;\u6216\u8005\u7528\u591a\u9636\u6bb5\u6784\u5efa\u3002<\/p>\n<p>\u591a\u9636\u6bb5\u6784\u5efa\u662f\u66f4\u5f7b\u5e95\u7684\u529e\u6cd5&#xff1a;\u6784\u5efa\u9636\u6bb5\u88c5\u7f16\u8bd1\u5de5\u5177\u548c\u4f9d\u8d56&#xff0c;\u8fd0\u884c\u9636\u6bb5\u53ea\u62f7\u6700\u7ec8\u4ea7\u7269\u3002<\/p>\n<p>FROM python:3.11-slim AS builder<br \/>\nWORKDIR \/app<br \/>\nCOPY requirements.txt .<br \/>\nRUN pip install &#8211;user &#8211;no-cache-dir -r requirements.txt<\/p>\n<p>FROM python:3.11-slim<br \/>\nWORKDIR \/app<br \/>\nCOPY &#8211;from&#061;builder \/root\/.local \/root\/.local<br \/>\nCOPY . .<br \/>\nENV PATH&#061;\/root\/.local\/bin:$PATH<br \/>\nCMD [&#034;python&#034;, &#034;main.py&#034;]<\/p>\n<p>\u8fd9\u6837\u6700\u7ec8\u955c\u50cf\u91cc\u4e0d\u5e26pip\u7684\u6784\u5efa\u7f13\u5b58&#xff0c;\u4f53\u79ef\u80fd\u5c0f\u4e0d\u5c11\u3002\u5177\u4f53\u5c0f\u591a\u5c11\u53d6\u51b3\u4e8e\u4f9d\u8d56&#xff0c;\u6211\u6ca1\u6709\u505a\u4e25\u683c\u7684\u5bf9\u6bd4\u6d4b\u8bd5&#xff0c;\u4f46\u65b9\u5411\u662f\u660e\u786e\u7684\u3002<\/p>\n<h3>\u6570\u636e\u6301\u4e45\u5316\u7684\u65b9\u6848\u9009\u62e9<\/h3>\n<p>\u56de\u5230\u5f00\u5934\u90a3\u4e2a\u6570\u636e\u4e22\u5931\u7684\u95ee\u9898&#xff0c;\u6700\u7ec8\u7684\u65b9\u6848\u662f\u7ed9 \/app\/data \u6302\u4e00\u4e2anamed volume&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">&#8211;name<\/span> processor <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-v<\/span> processor-data:\/app\/data <span class=\"token punctuation\">\\\\<\/span><br \/>\n  processor:latest<\/p>\n<p>\u8fd9\u6837\u5bb9\u5668\u91cd\u542f\u3001\u91cd\u5efa&#xff0c;\u6570\u636e\u90fd\u5728\u5377\u91cc\u3002\u9700\u8981\u5907\u4efd\u65f6&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">&#8211;rm<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-v<\/span> processor-data:\/data <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">-v<\/span> <span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token builtin class-name\">pwd<\/span><span class=\"token variable\">)<\/span><\/span>\/backup:\/backup <span class=\"token punctuation\">\\\\<\/span><br \/>\n  alpine <span class=\"token function\">tar<\/span> czf \/backup\/data.tar.gz <span class=\"token parameter variable\">-C<\/span> \/data <span class=\"token builtin class-name\">.<\/span><\/p>\n<p>\u7528\u4e00\u4e2a\u4e34\u65f6\u5bb9\u5668\u628a\u5377\u6302\u8fdb\u53bb\u6253\u5305&#xff0c;\u5bfc\u51fa\u5230\u5bbf\u4e3b\u673a\u3002\u6062\u590d\u53cd\u8fc7\u6765\u64cd\u4f5c\u3002<\/p>\n<h4>\u4ec0\u4e48\u6570\u636e\u8be5\u6302\u5377<\/h4>\n<p>\u4e0d\u662f\u6240\u6709\u6570\u636e\u90fd\u9700\u8981\u6301\u4e45\u5316\u3002\u6211\u7684\u5224\u65ad\u6807\u51c6&#xff1a;<\/p>\n<ul>\n<li>\u5fc5\u987b\u6301\u4e45\u5316&#xff1a;\u6570\u636e\u5e93\u6587\u4ef6\u3001\u7528\u6237\u4e0a\u4f20\u7684\u6587\u4ef6\u3001\u4efb\u52a1\u4e2d\u95f4\u72b6\u6001\u3001\u65e5\u5fd7&#xff08;\u5982\u679c\u9700\u8981\u957f\u671f\u4fdd\u7559&#xff09;<\/li>\n<li>\u4e0d\u9700\u8981\u6301\u4e45\u5316&#xff1a;\u7f13\u5b58\u3001\u4e34\u65f6\u6587\u4ef6\u3001\u53ef\u4ee5\u4ece\u6e90\u5934\u91cd\u5efa\u7684\u6570\u636e<\/li>\n<\/ul>\n<p>\u628a\u4e0d\u9700\u8981\u7684\u4e5f\u6302\u5377&#xff0c;\u53cd\u800c\u589e\u52a0\u7ba1\u7406\u6210\u672c&#xff0c;\u8fd8\u53ef\u80fd\u56e0\u4e3a\u5377\u91cc\u6b8b\u7559\u65e7\u6570\u636e\u5bfc\u81f4\u5947\u602a\u95ee\u9898\u3002<\/p>\n<h4>\u5377\u7684\u751f\u547d\u5468\u671f<\/h4>\n<p>docker rm \u5220\u5bb9\u5668\u4e0d\u4f1a\u5220named volume\u3002\u8981\u5220\u5377\u5f97\u5355\u72ec\u64cd\u4f5c&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> volume <span class=\"token function\">rm<\/span> processor-data<\/p>\n<p>\u6216\u8005\u6e05\u7406\u6240\u6709\u6ca1\u88ab\u4f7f\u7528\u7684\u5377&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> volume prune<\/p>\n<p>\u8fd9\u4e2a\u8bbe\u8ba1\u662f\u5408\u7406\u7684\u2014\u2014\u9632\u6b62\u8bef\u5220\u6570\u636e\u3002\u4f46\u53cd\u8fc7\u6765\u8bf4&#xff0c;\u5982\u679c\u4e0d\u6ce8\u610f&#xff0c;\u4f1a\u79ef\u7d2f\u4e00\u5806\u6ca1\u7528\u7684\u5377\u5360\u78c1\u76d8\u3002\u6211\u4e60\u60ef\u5b9a\u671f docker volume ls \u770b\u4e00\u773c\u3002<\/p>\n<h3>\u51e0\u4e2a\u503c\u5f97\u7559\u610f\u7684\u7ec6\u8282<\/h3>\n<p>\u5bb9\u5668\u5185\u770b\u5230\u7684\u6587\u4ef6\u7cfb\u7edf\u662f&#034;\u5408\u5e76\u89c6\u56fe&#034;\u3002ls \u770b\u5230\u7684\u65e2\u6709\u955c\u50cf\u5c42\u7684\u5185\u5bb9&#xff0c;\u4e5f\u6709\u53ef\u5199\u5c42\u7684\u5185\u5bb9&#xff0c;\u8fd8\u6709\u6302\u8f7d\u7684\u5185\u5bb9\u3002\u4f46 docker diff \u53ea\u663e\u793a\u53ef\u5199\u5c42\u76f8\u5bf9\u4e8e\u955c\u50cf\u5c42\u7684\u6539\u52a8&#xff0c;\u6302\u8f7d\u7684\u5185\u5bb9\u4e0d\u7b97\u5728\u5185\u3002<\/p>\n<p>\u6302\u8f7d\u8def\u5f84\u5fc5\u987b\u662f\u7edd\u5bf9\u8def\u5f84\u3002-v data:\/app\/data \u91cc\u7684 data \u5982\u679c\u4e0d\u662f\u5df2\u5b58\u5728\u7684named volume&#xff0c;Docker\u4f1a\u5f53\u6210named volume\u521b\u5efa&#xff1b;\u4f46\u5982\u679c\u662f .\/data:\/app\/data&#xff0c;\u76f8\u5bf9\u8def\u5f84\u4f1a\u88ab\u5f53\u6210bind mount\u3002\u8fd9\u4e2a\u884c\u4e3a\u5bb9\u6613\u6df7\u6dc6&#xff0c;\u5efa\u8bae\u5199\u6e05\u695a\u3002<\/p>\n<p>&#8211;mount \u8bed\u6cd5\u6bd4 -v \u66f4\u660e\u786e\u3002\u65b0\u7248\u672cDocker\u63a8\u8350\u7528 &#8211;mount&#xff0c;\u53c2\u6570\u540d\u6e05\u6670&#xff0c;\u51fa\u9519\u65f6\u63d0\u793a\u4e5f\u66f4\u597d&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  <span class=\"token parameter variable\">&#8211;mount<\/span> <span class=\"token assign-left variable\">type<\/span><span class=\"token operator\">&#061;<\/span>volume,source<span class=\"token operator\">&#061;<\/span>processor-data,target<span class=\"token operator\">&#061;<\/span>\/app\/data <span class=\"token punctuation\">\\\\<\/span><br \/>\n  processor:latest<\/p>\n<p>\u529f\u80fd\u4e0a\u548c -v \u7b49\u4ef7&#xff0c;\u4f46\u53ef\u8bfb\u6027\u66f4\u597d\u3002\u6211\u5728\u811a\u672c\u91cc\u66f4\u503e\u5411\u7528\u8fd9\u4e2a\u3002<\/p>\n<p>overlay2\u7684\u6027\u80fd\u3002\u5199\u65f6\u590d\u5236\u7684\u673a\u5236\u610f\u5473\u7740\u9996\u6b21\u5199\u4e00\u4e2a\u5927\u6587\u4ef6\u4f1a\u6709\u62f7\u8d1d\u5f00\u9500\u3002\u5bf9\u4e8e\u5199\u5bc6\u96c6\u7684\u573a\u666f&#xff0c;\u6302\u8f7d\u5377&#xff08;\u5c24\u5176\u662fnamed volume&#xff09;\u901a\u5e38\u6bd4\u5199\u5728\u53ef\u5199\u5c42\u6027\u80fd\u66f4\u597d\u3002\u8fd9\u4e00\u70b9\u6211\u5728\u5b9e\u9645\u9879\u76ee\u91cc\u611f\u53d7\u5230\u8fc7&#xff0c;\u4f46\u6ca1\u6709\u505a\u8fc7\u7cbe\u786e\u7684\u57fa\u51c6\u6d4b\u8bd5&#xff0c;\u53ea\u80fd\u8bf4\u65b9\u5411\u5982\u6b64&#xff0c;\u5177\u4f53\u6570\u5b57\u56e0\u573a\u666f\u800c\u5f02\u3002<\/p>\n<h3>\u5199\u5728\u6700\u540e<\/h3>\n<p>Docker\u7684\u5b58\u50a8\u673a\u5236\u672c\u8eab\u4e0d\u590d\u6742&#xff0c;\u6838\u5fc3\u5c31\u662f&#034;\u5206\u5c42\u53ea\u8bfb&#043;\u53ef\u5199\u5c42&#043;\u5377\u6302\u8f7d&#034;\u8fd9\u4e09\u4ef6\u4e8b\u3002\u4f46\u5b9e\u9645\u7528\u8d77\u6765&#xff0c;\u6302\u8f7d\u8986\u76d6\u3001\u6743\u9650\u3001\u751f\u547d\u5468\u671f\u8fd9\u4e9b\u7ec6\u8282\u5bb9\u6613\u51fa\u95ee\u9898\u3002<\/p>\n<p>\u6211\u7684\u7ecf\u9a8c\u662f&#xff1a;\u5f00\u53d1\u548c\u751f\u4ea7\u7684\u6302\u8f7d\u7b56\u7565\u8981\u5206\u5f00\u8003\u8651\u3002\u5f00\u53d1\u56fe\u65b9\u4fbf&#xff0c;\u7528bind mount\u540c\u6b65\u4ee3\u7801&#xff1b;\u751f\u4ea7\u56fe\u7a33\u5b9a&#xff0c;\u7528named volume\u5b58\u6570\u636e\u3002\u522b\u628a\u5f00\u53d1\u65f6\u7684\u4e60\u60ef\u5e26\u5230\u751f\u4ea7&#xff0c;\u4e5f\u522b\u4e3a\u4e86\u7701\u4e8b\u628a\u8be5\u6301\u4e45\u5316\u7684\u6570\u636e\u7559\u5728\u53ef\u5199\u5c42\u3002<\/p>\n<p>\u81f3\u4e8e\u5f00\u5934\u90a3\u4e2a\u6570\u636e\u4e22\u5931\u7684\u95ee\u9898&#xff0c;\u4e8b\u540e\u60f3\u60f3\u5176\u5b9e\u662f\u4e2a\u4f4e\u7ea7\u9519\u8bef&#xff0c;\u4f46\u5b83\u8ba9\u6211\u628aDocker\u5b58\u50a8\u8fd9\u5757\u5f7b\u5e95\u7406\u6e05\u4e86\u4e00\u904d\u3002\u5982\u679c\u4f60\u4e5f\u5728\u7528Docker\u8dd1\u6709\u72b6\u6001\u670d\u52a1&#xff0c;\u5efa\u8bae\u68c0\u67e5\u4e00\u4e0b\u5173\u952e\u6570\u636e\u76ee\u5f55\u662f\u4e0d\u662f\u90fd\u6b63\u786e\u6302\u8f7d\u4e86\u2014\u2014\u8fd9\u4e2a\u95ee\u9898\u4e0d\u67e5\u6ca1\u4e8b&#xff0c;\u4e00\u67e5\u53ef\u80fd\u5c31\u53d1\u73b0\u51e0\u4e2a\u6f0f\u7f51\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u4e00\u4e2a\u6570\u636e\u4e22\u5931\u7684\u95ee\u9898\u8bf4\u8d77<br \/>\n\u524d\u6bb5\u65f6\u95f4\u5728\u505a\u4e00\u4e2aPython\u6570\u636e\u5904\u7406\u670d\u52a1&#xff0c;\u7528Docker\u8dd1\u4efb\u52a1\u3002\u670d\u52a1\u903b\u8f91\u5f88\u7b80\u5355&#xff1a;\u5bb9\u5668\u542f\u52a8\u540e\u4ece\u6d88\u606f\u961f\u5217\u62c9\u4efb\u52a1&#xff0c;\u628a\u4e2d\u95f4\u7ed3\u679c\u5199\u5230 \/app\/data \u76ee\u5f55&#xff0c;\u5904\u7406\u5b8c\u518d\u4e0a\u4f20\u3002\u672c\u5730\u5f00\u53d1\u65f6\u4e00\u5207\u6b63\u5e38&#xff0c;\u4f46\u90e8\u7f72\u5230\u6d4b\u8bd5\u73af\u5883\u540e&#xff0c;\u8fd0\u7ef4\u53cd\u9988\u8bf4\u5bb9\u5668\u91cd\u542f\u540e \/app\/data \u91cc\u7684\u6587\u4ef6\u5168\u6ca1\u4e86\u3002<br \/>\n\u6211\u7b2c\u4e00\u53cd\u5e94\u662f\u4ee3\u7801\u91cc\u54ea\u91cc\u7684\u6e05\u7406\u903b\u8f91\u5199\u9519\u4e86&#xff0c;\u7ffb\u4e86\u4e00\u904d\u6ca1\u53d1\u73b0\u95ee\u9898\u3002\u540e\u6765\u624d\u610f\u8bc6\u5230&#xff0c;\/a<\/p>\n","protected":false},"author":2,"featured_media":113826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,81,292,121,44],"topic":[],"class_list":["post-113830","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-docker","tag-python","tag-292","tag-121","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/113830.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4ece\u4e00\u4e2a\u6570\u636e\u4e22\u5931\u7684\u95ee\u9898\u8bf4\u8d77 \u524d\u6bb5\u65f6\u95f4\u5728\u505a\u4e00\u4e2aPython\u6570\u636e\u5904\u7406\u670d\u52a1&#xff0c;\u7528Docker\u8dd1\u4efb\u52a1\u3002\u670d\u52a1\u903b\u8f91\u5f88\u7b80\u5355&#xff1a;\u5bb9\u5668\u542f\u52a8\u540e\u4ece\u6d88\u606f\u961f\u5217\u62c9\u4efb\u52a1&#xff0c;\u628a\u4e2d\u95f4\u7ed3\u679c\u5199\u5230 \/app\/data \u76ee\u5f55&#xff0c;\u5904\u7406\u5b8c\u518d\u4e0a\u4f20\u3002\u672c\u5730\u5f00\u53d1\u65f6\u4e00\u5207\u6b63\u5e38&#xff0c;\u4f46\u90e8\u7f72\u5230\u6d4b\u8bd5\u73af\u5883\u540e&#xff0c;\u8fd0\u7ef4\u53cd\u9988\u8bf4\u5bb9\u5668\u91cd\u542f\u540e \/app\/data \u91cc\u7684\u6587\u4ef6\u5168\u6ca1\u4e86\u3002 \u6211\u7b2c\u4e00\u53cd\u5e94\u662f\u4ee3\u7801\u91cc\u54ea\u91cc\u7684\u6e05\u7406\u903b\u8f91\u5199\u9519\u4e86&#xff0c;\u7ffb\u4e86\u4e00\u904d\u6ca1\u53d1\u73b0\u95ee\u9898\u3002\u540e\u6765\u624d\u610f\u8bc6\u5230&#xff0c;\/a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/113830.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-07T10:25:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261007102528-6ac61e18509e7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/113830.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/113830.html\",\"name\":\"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-07T10:25:37+00:00\",\"dateModified\":\"2026-10-07T10:25:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/113830.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/113830.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/113830.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/113830.html","og_locale":"zh_CN","og_type":"article","og_title":"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4ece\u4e00\u4e2a\u6570\u636e\u4e22\u5931\u7684\u95ee\u9898\u8bf4\u8d77 \u524d\u6bb5\u65f6\u95f4\u5728\u505a\u4e00\u4e2aPython\u6570\u636e\u5904\u7406\u670d\u52a1&#xff0c;\u7528Docker\u8dd1\u4efb\u52a1\u3002\u670d\u52a1\u903b\u8f91\u5f88\u7b80\u5355&#xff1a;\u5bb9\u5668\u542f\u52a8\u540e\u4ece\u6d88\u606f\u961f\u5217\u62c9\u4efb\u52a1&#xff0c;\u628a\u4e2d\u95f4\u7ed3\u679c\u5199\u5230 \/app\/data \u76ee\u5f55&#xff0c;\u5904\u7406\u5b8c\u518d\u4e0a\u4f20\u3002\u672c\u5730\u5f00\u53d1\u65f6\u4e00\u5207\u6b63\u5e38&#xff0c;\u4f46\u90e8\u7f72\u5230\u6d4b\u8bd5\u73af\u5883\u540e&#xff0c;\u8fd0\u7ef4\u53cd\u9988\u8bf4\u5bb9\u5668\u91cd\u542f\u540e \/app\/data \u91cc\u7684\u6587\u4ef6\u5168\u6ca1\u4e86\u3002 \u6211\u7b2c\u4e00\u53cd\u5e94\u662f\u4ee3\u7801\u91cc\u54ea\u91cc\u7684\u6e05\u7406\u903b\u8f91\u5199\u9519\u4e86&#xff0c;\u7ffb\u4e86\u4e00\u904d\u6ca1\u53d1\u73b0\u95ee\u9898\u3002\u540e\u6765\u624d\u610f\u8bc6\u5230&#xff0c;\/a","og_url":"https:\/\/www.wsisp.com\/helps\/113830.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-07T10:25:37+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261007102528-6ac61e18509e7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/113830.html","url":"https:\/\/www.wsisp.com\/helps\/113830.html","name":"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-07T10:25:37+00:00","dateModified":"2026-10-07T10:25:37+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/113830.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/113830.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/113830.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Docker\u955c\u50cf\u5206\u5c42\u4e0e\u5377\u6302\u8f7d\u5b9e\u6218\uff1a\u4ece\u5b58\u50a8\u539f\u7406\u5230\u6570\u636e\u6301\u4e45\u5316\u8e29\u5751\u8bb0\u5f55"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/113830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=113830"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/113830\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/113826"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=113830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=113830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=113830"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=113830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}