{"id":4244,"date":"2024-11-11T17:59:19","date_gmt":"2024-11-11T09:59:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/4244\/"},"modified":"2024-11-11T17:59:19","modified_gmt":"2024-11-11T09:59:19","slug":"%e4%bf%9d%e7%95%99%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/4244\/","title":{"rendered":"\u4fdd\u7559\u6570\u636e\u5e93"},"content":{"rendered":"<h1>\u4fdd\u7559\u6570\u636e\u5e93<\/h1>\n<p>\u5982\u679c\u60a8\u6ca1\u6709\u6ce8\u610f\u5230\uff0c\u6bcf\u6b21\u542f\u52a8\u5bb9\u5668\u65f6\uff0c\u60a8\u7684\u5f85\u529e\u4e8b\u9879\u5217\u8868\u90fd\u662f\u7a7a\u7684\u3002\u4e3a\u4ec0\u4e48\u662f\u8fd9\u6837\uff1f\u5728\u8fd9\u4e00\u90e8\u5206\u4e2d\uff0c\u60a8\u5c06\u6df1\u5165\u4e86\u89e3\u5bb9\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3002<\/p>\n<h2><\/h2>\n<p>\u5f53\u5bb9\u5668\u8fd0\u884c\u65f6\uff0c\u5b83\u4f1a\u4f7f\u7528\u6620\u50cf\u4e2d\u7684\u5404\u4e2a\u5c42\u4f5c\u4e3a\u5176\u6587\u4ef6\u7cfb\u7edf\u3002\u6bcf\u4e2a\u5bb9\u5668\u8fd8\u62e5\u6709\u81ea\u5df1\u7684\u201c\u4e34\u65f6\u7a7a\u95f4\u201d\u6765\u521b\u5efa\/\u66f4\u65b0\/\u5220\u9664\u6587\u4ef6\u3002\u5373\u4f7f\u5b83\u4eec\u4f7f\u7528\u76f8\u540c\u7684\u56fe\u50cf\uff0c\u4efb\u4f55\u66f4\u6539\u90fd\u4e0d\u4f1a\u5728\u53e6\u4e00\u4e2a\u5bb9\u5668\u4e2d\u770b\u5230\u3002<\/p>\n<h3><\/h3>\n<p>\u8981\u67e5\u770b\u5176\u5b9e\u9645\u6548\u679c\uff0c\u60a8\u5c06\u542f\u52a8\u4e24\u4e2a\u5bb9\u5668\u3002\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u60a8\u5c06\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u3002\u5728\u53e6\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u60a8\u5c06\u9a8c\u8bc1\u8be5\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002\u60a8\u5c06\u770b\u5230\u7684\u662f\uff0c\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\u521b\u5efa\u7684\u6587\u4ef6\u5728\u53e6\u4e00\u4e2a\u5bb9\u5668\u4e2d\u4e0d\u53ef\u7528\u3002<\/p>\n<ol>\n<li>\n<p>\u542f\u52a8 Alpine \u5bb9\u5668\u5e76\u8bbf\u95ee\u5176 shell\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>$<\/span> docker run -ti --name<span>=<\/span>mytest alpine <\/span><\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>\u5728\u5bb9\u5668\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a<code>greeting.txt<\/code>\u5305\u542b inside \u7684\u6587\u4ef6<code>hello<\/code>\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>\/ # echo \"hello\" &gt; greeting.txt <\/span><\/span><\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>\u9000\u51fa\u5bb9\u5668\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>\/ # exit <\/span><\/span><\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>\u8fd0\u884c\u4e00\u4e2a\u65b0\u7684 Alpine \u5bb9\u5668\u5e76\u4f7f\u7528<code>cat<\/code>\u547d\u4ee4\u9a8c\u8bc1\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>$<\/span> docker run alpine cat greeting.txt <\/span><\/span><\/code><\/pre>\n<p>\u60a8\u5e94\u8be5\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\u7684\u8f93\u51fa\uff0c\u8868\u660e\u65b0\u5bb9\u5668\u4e2d\u4e0d\u5b58\u5728\u8be5\u6587\u4ef6\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>cat: can't open 'greeting.txt': No such file or directory <\/span><\/span><\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>\u7ee7\u7eed\u4f7f\u7528<code>docker ps --all<\/code>\u83b7\u53d6 ID \u6765\u5220\u9664\u5bb9\u5668\uff0c\u7136\u540e<code>docker rm -f &lt;container-id&gt;<\/code>\u5220\u9664\u5bb9\u5668\u3002<\/p>\n<\/li>\n<\/ol>\n<h2><\/h2>\n<p>\u901a\u8fc7\u4e4b\u524d\u7684\u5b9e\u9a8c\uff0c\u60a8\u770b\u5230\u6bcf\u4e2a\u5bb9\u5668\u6bcf\u6b21\u542f\u52a8\u65f6\u90fd\u4ece\u56fe\u50cf\u5b9a\u4e49\u5f00\u59cb\u3002\u867d\u7136\u5bb9\u5668\u53ef\u4ee5\u521b\u5efa\u3001\u66f4\u65b0\u548c\u5220\u9664\u6587\u4ef6\uff0c\u4f46\u5f53\u60a8\u5220\u9664\u5bb9\u5668\u65f6\uff0c\u8fd9\u4e9b\u66f4\u6539\u5c06\u4f1a\u4e22\u5931\uff0c\u5e76\u4e14 Docker \u4f1a\u9694\u79bb\u5bf9\u8be5\u5bb9\u5668\u7684\u6240\u6709\u66f4\u6539\u3002\u6709\u4e86\u5377\uff0c\u4f60\u5c31\u53ef\u4ee5\u6539\u53d8\u8fd9\u4e00\u5207\u3002<\/p>\n<p>\u63d0\u4f9b\u4e86\u5c06\u5bb9\u5668\u7684\u7279\u5b9a\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\u8fde\u63a5\u56de\u4e3b\u673a\u7684\u80fd\u529b\u3002\u5982\u679c\u5728\u5bb9\u5668\u4e2d\u6302\u8f7d\u76ee\u5f55\uff0c\u5219\u8be5\u76ee\u5f55\u4e2d\u7684\u66f4\u6539\u4e5f\u4f1a\u5728\u4e3b\u673a\u4e0a\u770b\u5230\u3002\u5982\u679c\u60a8\u5728\u5bb9\u5668\u91cd\u65b0\u542f\u52a8\u65f6\u6302\u8f7d\u76f8\u540c\u7684\u76ee\u5f55\uff0c\u60a8\u5c06\u770b\u5230\u76f8\u540c\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u5377\u6709\u4e24\u79cd\u4e3b\u8981\u7c7b\u578b\u3002\u60a8\u6700\u7ec8\u5c06\u4f7f\u7528\u4e24\u8005\uff0c\u4f46\u60a8\u5c06\u4ece\u5377\u5b89\u88c5\u5f00\u59cb\u3002<\/p>\n<h2><\/h2>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ctodo \u5e94\u7528\u7a0b\u5e8f\u5c06\u5176\u6570\u636e\u5b58\u50a8\u5728 <code>\/etc\/todos\/todo.db<\/code>\u5bb9\u5668\u6587\u4ef6\u7cfb\u7edf\u7684 SQLite \u6570\u636e\u5e93\u4e2d\u3002\u5982\u679c\u60a8\u4e0d\u719f\u6089 SQLite\uff0c\u4e0d\u7528\u62c5\u5fc3\uff01\u5b83\u53ea\u662f\u4e00\u4e2a\u5c06\u6240\u6709\u6570\u636e\u5b58\u50a8\u5728\u5355\u4e2a\u6587\u4ef6\u4e2d\u7684\u5173\u7cfb\u6570\u636e\u5e93\u3002\u867d\u7136\u8fd9\u5bf9\u4e8e\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\u4e0d\u662f\u6700\u597d\u7684\uff0c\u4f46\u5b83\u9002\u7528\u4e8e\u5c0f\u578b\u6f14\u793a\u3002\u7a0d\u540e\u60a8\u5c06\u4e86\u89e3\u5982\u4f55\u5c06\u5176\u5207\u6362\u5230\u4e0d\u540c\u7684\u6570\u636e\u5e93\u5f15\u64ce\u3002<\/p>\n<p>\u7531\u4e8e\u6570\u636e\u5e93\u662f\u5355\u4e2a\u6587\u4ef6\uff0c\u5982\u679c\u60a8\u53ef\u4ee5\u5c06\u8be5\u6587\u4ef6\u4fdd\u7559\u5728\u4e3b\u673a\u4e0a\u5e76\u5c06\u5176\u53ef\u4f9b\u4e0b\u4e00\u4e2a\u5bb9\u5668\u4f7f\u7528\uff0c\u90a3\u4e48\u5b83\u5e94\u8be5\u80fd\u591f\u4ece\u4e0a\u4e00\u4e2a\u5bb9\u5668\u505c\u6b62\u7684\u5730\u65b9\u7ee7\u7eed\u3002\u901a\u8fc7\u521b\u5efa\u5377\u5e76\u5c06\u5176\u9644\u52a0\uff08\u901a\u5e38\u79f0\u4e3a\u201c\u5b89\u88c5\u201d\uff09\u5230\u5b58\u50a8\u6570\u636e\u7684\u76ee\u5f55\uff0c\u60a8\u53ef\u4ee5\u4fdd\u7559\u6570\u636e\u3002\u5f53\u5bb9\u5668\u5199\u5165\u6587\u4ef6\u65f6<code>todo.db<\/code>\uff0c\u5b83\u5c06\u6570\u636e\u4fdd\u5b58\u5230\u5377\u4e2d\u7684\u4e3b\u673a\u3002<\/p>\n<p>\u5982\u524d\u6240\u8ff0\uff0c\u60a8\u5c06\u4f7f\u7528\u5377\u5b89\u88c5\u3002\u5c06\u5377\u6302\u8f7d\u89c6\u4e3a\u4e0d\u900f\u660e\u7684\u6570\u636e\u6876\u3002 Docker \u5b8c\u5168\u7ba1\u7406\u5377\uff0c\u5305\u62ec\u78c1\u76d8\u4e0a\u7684\u5b58\u50a8\u4f4d\u7f6e\u3002\u60a8\u53ea\u9700\u8981\u8bb0\u4f4f\u5377\u7684\u540d\u79f0\u5373\u53ef\u3002<\/p>\n<h3><\/h3>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 CLI \u6216 Docker Desktop \u7684\u56fe\u5f62\u754c\u9762\u521b\u5efa\u5377\u5e76\u542f\u52a8\u5bb9\u5668\u3002<\/p>\n<p> \u547d\u4ee4\u884c\u754c\u9762 Docker \u684c\u9762 <\/p>\n<hr>\n<ol>\n<li>\n<p>\u4f7f\u7528\u547d\u4ee4\u521b\u5efa\u5377<code>docker volume create<\/code>\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>$<\/span> docker volume create todo-db <\/span><\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>\u4f7f\u7528 \u518d\u6b21\u505c\u6b62\u5e76\u5220\u9664\u5f85\u529e\u4e8b\u9879\u5e94\u7528\u7a0b\u5e8f\u5bb9\u5668<code>docker rm -f &lt;id&gt;<\/code>\uff0c\u56e0\u4e3a\u5b83\u4ecd\u5728\u8fd0\u884c\u800c\u4e0d\u4f7f\u7528\u6301\u4e45\u5377\u3002<\/p>\n<\/li>\n<li>\n<p>\u542f\u52a8 todo \u5e94\u7528\u7a0b\u5e8f\u5bb9\u5668\uff0c\u4f46\u6dfb\u52a0<code>--mount<\/code>\u6307\u5b9a\u5377\u5b89\u88c5\u7684\u9009\u9879\u3002\u4e3a\u5377\u547d\u540d\uff0c\u5e76\u5c06\u5176\u5b89\u88c5\u5230<code>\/etc\/todos<\/code>\u5bb9\u5668\u4e2d\uff0c\u8be5\u5bb9\u5668\u6355\u83b7\u5728\u8be5\u8def\u5f84\u4e2d\u521b\u5efa\u7684\u6240\u6709\u6587\u4ef6\u3002<\/p>\n<p> <span> <\/span> <span> <\/span> <\/p>\n<pre><code><span><span><span>$<\/span> docker run -dp 127.0.0.1:3000:3000 --mount <span>type<\/span><span>=<\/span>volume,src<span>=<\/span>todo-db,target<span>=<\/span>\/etc\/todos getting-started <\/span><\/span><\/code><\/pre>\n<blockquote>\n<p><strong>\u7b14\u8bb0<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528 Git Bash\uff0c\u5219\u5fc5\u987b\u5bf9\u6b64\u547d\u4ee4\u4f7f\u7528\u4e0d\u540c\u7684\u8bed\u6cd5\u3002<\/p>\n<p>   <span> <\/span><br \/>\n   <span> <\/span> <\/p>\n<pre><code><span><span><span>$<\/span> docker run -dp 127.0.0.1:3000:3000 --mount <span>type<\/span><span>=<\/span>volume,src<span>=<\/span>todo-db,target<span>=<\/span>\/\/etc\/todos getting-started <\/span><\/span><\/code><\/pre>\n<p>\u6709\u5173 Git Bash \u8bed\u6cd5\u5dee\u5f02\u7684\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 \u3002<\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<p>\u521b\u5efa\u5377\uff1a<\/p>\n<ol>\n<li>\u5728 Docker Desktop \u4e2d\u9009\u62e9<strong>\u5377\u3002<\/strong><\/li>\n<li>\u5728<strong>\u5377<\/strong>\u4e2d\uff0c\u9009\u62e9<strong>\u521b\u5efa<\/strong>\u3002<\/li>\n<li>\u6307\u5b9a<code>todo-db<\/code>\u4e3a\u5377\u540d\u79f0\uff0c\u7136\u540e\u9009\u62e9<strong>\u201c\u521b\u5efa\u201d<\/strong>\u3002<\/li>\n<\/ol>\n<p>\u8981\u505c\u6b62\u5e76\u5220\u9664\u5e94\u7528\u7a0b\u5e8f\u5bb9\u5668\uff1a<\/p>\n<ol>\n<li>\u5728 Docker Desktop \u4e2d\u9009\u62e9<strong>\u5bb9\u5668\u3002<\/strong><\/li>\n<li>\u5728\u5bb9\u5668\u7684<strong>\u64cd\u4f5c<\/strong>\u5217\u4e2d\u9009\u62e9<strong>\u5220\u9664\u3002<\/strong><strong><\/strong><\/li>\n<\/ol>\n<p>\u8981\u542f\u52a8\u6302\u8f7d\u5377\u7684 todo \u5e94\u7528\u7a0b\u5e8f\u5bb9\u5668\uff1a<\/p>\n<ol>\n<li>\n<p>\u9009\u62e9 Docker Desktop \u9876\u90e8\u7684\u641c\u7d22\u6846\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728\u641c\u7d22\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9<strong>\u56fe\u50cf<\/strong>\u9009\u9879\u5361\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728\u641c\u7d22\u6846\u4e2d\uff0c\u6307\u5b9a\u5bb9\u5668\u540d\u79f0<code>getting-started<\/code>\u3002<\/p>\n<blockquote>\n<p><strong>\u63d0\u793a<\/strong><\/p>\n<p>\u4f7f\u7528\u641c\u7d22\u8fc7\u6ee4\u5668\u8fc7\u6ee4\u56fe\u50cf\u5e76\u4ec5\u663e\u793a<strong>\u672c\u5730\u56fe\u50cf<\/strong>\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u9009\u62e9\u60a8\u7684\u56fe\u50cf\uff0c\u7136\u540e\u9009\u62e9<strong>\u201c\u8fd0\u884c\u201d<\/strong>\u3002<\/p>\n<\/li>\n<li>\n<p>\u9009\u62e9<strong>\u53ef\u9009\u8bbe\u7f6e<\/strong>\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728<strong>\u4e3b\u673a\u7aef\u53e3<\/strong>\u4e2d\uff0c\u6307\u5b9a\u7aef\u53e3\uff0c\u4f8b\u5982<code>3000<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728<strong>\u4e3b\u673a\u8def\u5f84<\/strong>\u4e2d\uff0c\u6307\u5b9a\u5377\u7684\u540d\u79f0<code>todo-db<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728<strong>\u5bb9\u5668\u8def\u5f84<\/strong>\u4e2d\uff0c\u6307\u5b9a<code>\/etc\/todos<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u9009\u62e9<strong>\u8fd0\u884c<\/strong>\u3002<\/p>\n<\/li>\n<\/ol>\n<hr>\n<h3><\/h3>\n<ol>\n<li>\n<p>\u5bb9\u5668\u542f\u52a8\u540e\uff0c\u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u5e76\u5c06\u4e00\u4e9b\u9879\u76ee\u6dfb\u52a0\u5230\u60a8\u7684\u5f85\u529e\u4e8b\u9879\u5217\u8868\u4e2d\u3002<\/p>\n<p> <img decoding=\"async\" src=\"https:\/\/docker.github.net.cn\/get-started\/images\/items-added.webp\" class=\"aligncenter\" title=\"\u4fdd\u7559\u6570\u636e\u5e93\u63d2\u56fe\" alt=\"\u4fdd\u7559\u6570\u636e\u5e93\u63d2\u56fe\" \/> <img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/docker.github.net.cn\/get-started\/images\/items-added.webp\" title=\"\u4fdd\u7559\u6570\u636e\u5e93\u63d2\u56fe1\" alt=\"\u4fdd\u7559\u6570\u636e\u5e93\u63d2\u56fe1\" \/> <\/li>\n<li>\n<p>\u505c\u6b62\u5e76\u5220\u9664\u5f85\u529e\u4e8b\u9879\u5e94\u7528\u7a0b\u5e8f\u7684\u5bb9\u5668\u3002\u4f7f\u7528 Docker Desktop \u6216<code>docker ps<\/code>\u83b7\u53d6 ID\uff0c\u7136\u540e<code>docker rm -f &lt;id&gt;<\/code>\u5c06\u5176\u5220\u9664\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u524d\u9762\u7684\u6b65\u9aa4\u542f\u52a8\u4e00\u4e2a\u65b0\u5bb9\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u3002\u60a8\u5e94\u8be5\u4f1a\u770b\u5230\u60a8\u7684\u9879\u76ee\u4ecd\u5728\u5217\u8868\u4e2d\u3002<\/p>\n<\/li>\n<li>\n<p>\u68c0\u67e5\u5b8c\u6e05\u5355\u540e\uff0c\u8bf7\u7ee7\u7eed\u79fb\u9664\u5bb9\u5668\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u60a8\u73b0\u5728\u5df2\u7ecf\u4e86\u89e3\u4e86\u5982\u4f55\u4fdd\u5b58\u6570\u636e\u3002<\/p>\n<h2><\/h2>\n<p>\u5f88\u591a\u4eba\u7ecf\u5e38\u95ee\u201c\u5f53\u6211\u4f7f\u7528\u5377\u65f6\uff0cDocker \u5c06\u6211\u7684\u6570\u636e\u5b58\u50a8\u5728\u54ea\u91cc\uff1f\u201d\u5982\u679c\u4f60\u60f3\u77e5\u9053\uff0c\u53ef\u4ee5\u4f7f\u7528<code>docker volume inspect<\/code>\u547d\u4ee4\u3002<\/p>\n<p><span> <\/span><br \/>\n<span> <\/span> <\/p>\n<pre><code><span><span><span>$<\/span> docker volume inspect todo-db <\/span><\/span><span><span><span>[ <\/span><\/span><\/span><span><span><span> { <\/span><\/span><\/span><span><span><span> \"CreatedAt\": \"2019-09-26T02:18:36Z\", <\/span><\/span><\/span><span><span><span> \"Driver\": \"local\", <\/span><\/span><\/span><span><span><span> \"Labels\": {}, <\/span><\/span><\/span><span><span><span> \"Mountpoint\": \"\/var\/lib\/docker\/volumes\/todo-db\/_data\", <\/span><\/span><\/span><span><span><span> \"Name\": \"todo-db\", <\/span><\/span><\/span><span><span><span> \"Options\": {}, <\/span><\/span><\/span><span><span><span> \"Scope\": \"local\" <\/span><\/span><\/span><span><span><span> } <\/span><\/span><\/span><span><span><span>] <\/span><\/span><\/span><\/code><\/pre>\n<p>\u8fd9<code>Mountpoint<\/code>\u662f\u78c1\u76d8\u4e0a\u6570\u636e\u7684\u5b9e\u9645\u4f4d\u7f6e\u3002\u8bf7\u6ce8\u610f\uff0c\u5728\u5927\u591a\u6570\u8ba1\u7b97\u673a\u4e0a\uff0c\u60a8\u9700\u8981\u5177\u6709 root \u8bbf\u95ee\u6743\u9650\u624d\u80fd\u4ece\u4e3b\u673a\u8bbf\u95ee\u6b64\u76ee\u5f55\u3002<\/p>\n<h2><\/h2>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5b66\u4e60\u4e86\u5982\u4f55\u4fdd\u7559\u5bb9\u5668\u6570\u636e\u3002<\/p>\n<p>\u76f8\u5173\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<h2><\/h2>\n<p>\u63a5\u4e0b\u6765\uff0c\u60a8\u5c06\u4e86\u89e3\u5982\u4f55\u4f7f\u7528\u7ed1\u5b9a\u5b89\u88c5\u66f4\u6709\u6548\u5730\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4fdd\u7559\u6570\u636e\u5e93 \u5982\u679c\u60a8\u6ca1\u6709\u6ce8\u610f\u5230\uff0c\u6bcf\u6b21\u542f\u52a8\u5bb9\u5668\u65f6\uff0c\u60a8\u7684\u5f85\u529e\u4e8b\u9879\u5217\u8868\u90fd\u662f\u7a7a\u7684\u3002\u4e3a\u4ec0\u4e48\u662f\u8fd9\u6837\uff1f\u5728\u8fd9\u4e00\u90e8\u5206\u4e2d\uff0c\u60a8\u5c06\u6df1\u5165\u4e86\u89e3\u5bb9\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3002 \u5f53\u5bb9\u5668\u8fd0\u884c\u65f6\uff0c\u5b83\u4f1a\u4f7f\u7528\u6620\u50cf\u4e2d\u7684\u5404\u4e2a\u5c42\u4f5c\u4e3a\u5176\u6587\u4ef6\u7cfb\u7edf\u3002\u6bcf\u4e2a\u5bb9\u5668\u8fd8\u62e5\u6709\u81ea\u5df1\u7684\u201c\u4e34\u65f6\u7a7a\u95f4\u201d\u6765\u521b\u5efa\/\u66f4\u65b0\/\u5220\u9664\u6587\u4ef6\u3002\u5373\u4f7f\u5b83\u4eec\u4f7f\u7528\u76f8\u540c\u7684\u56fe\u50cf\uff0c\u4efb\u4f55\u66f4\u6539\u90fd\u4e0d\u4f1a\u5728\u53e6\u4e00\u4e2a\u5bb9\u5668\u4e2d\u770b\u5230\u3002 \u8981\u67e5\u770b\u5176\u5b9e\u9645\u6548\u679c\uff0c\u60a8\u5c06\u542f\u52a8\u4e24\u4e2a\u5bb9\u5668\u3002\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u60a8\u5c06\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u3002\u5728\u53e6\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u60a8\u5c06\u9a8c\u8bc1\u8be5\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002\u60a8\u5c06\u770b\u5230\u7684\u662f\uff0c\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\u521b\u5efa\u7684\u6587\u4ef6\u5728\u53e6\u4e00\u4e2a\u5bb9\u5668\u4e2d\u4e0d\u53ef\u7528\u3002 \u542f\u52a8 Alpine \u5bb9\u5668\u5e76\u8bbf\u95ee\u5176 shell\u3002 $ docker run -ti &#8211;name=mytest alpine \u5728\u5bb9\u5668\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2agreeting.txt\u5305\u542b inside \u7684\u6587\u4ef6hello\u3002 \/ # echo &#8220;hello&#8221; &gt; greeting.txt \u9000\u51fa\u5bb9\u5668\u3002 \/ # exit \u8fd0\u884c\u4e00\u4e2a\u65b0\u7684 Alpine \u5bb9\u5668\u5e76\u4f7f\u7528cat\u547d\u4ee4\u9a8c\u8bc1\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728\u3002 $ docker run alpine cat greeting.txt \u60a8\u5e94\u8be5\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\u7684\u8f93\u51fa\uff0c\u8868\u660e\u65b0\u5bb9\u5668\u4e2d\u4e0d\u5b58\u5728\u8be5\u6587\u4ef6\u3002 cat: can&#8217;t open &#8216;greeting.txt&#8217;: No such file or directory \u7ee7\u7eed\u4f7f\u7528docker ps &#8211;all\u83b7\u53d6 ID \u6765\u5220\u9664\u5bb9\u5668\uff0c\u7136\u540edocker rm -f &lt;container-id&gt;\u5220\u9664\u5bb9\u5668\u3002 \u901a\u8fc7\u4e4b\u524d\u7684\u5b9e\u9a8c\uff0c\u60a8\u770b\u5230\u6bcf\u4e2a\u5bb9\u5668\u6bcf\u6b21\u542f\u52a8\u65f6\u90fd\u4ece\u56fe\u50cf\u5b9a\u4e49\u5f00\u59cb\u3002\u867d\u7136\u5bb9\u5668\u53ef\u4ee5\u521b\u5efa\u3001\u66f4\u65b0\u548c\u5220\u9664\u6587\u4ef6\uff0c\u4f46\u5f53\u60a8\u5220\u9664\u5bb9\u5668\u65f6\uff0c\u8fd9\u4e9b\u66f4\u6539\u5c06\u4f1a\u4e22\u5931\uff0c\u5e76\u4e14 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-4244","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4244","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=4244"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4244\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=4244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=4244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=4244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}