{"id":54873,"date":"2025-08-13T12:19:49","date_gmt":"2025-08-13T04:19:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54873.html"},"modified":"2025-08-13T12:19:49","modified_gmt":"2025-08-13T04:19:49","slug":"docker%e4%b8%8edocker-compose%ef%bc%9a%e5%ae%b9%e5%99%a8%e4%b8%96%e7%95%8c%e7%9a%84%e5%8d%95%e5%85%b5%e4%bd%9c%e6%88%98%e4%b8%8e%e5%86%9b%e5%9b%a2%e6%8c%87%e6%8c%a5%e5%ae%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54873.html","title":{"rendered":"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d"},"content":{"rendered":"<p>\u5728\u5bb9\u5668\u5316\u6280\u672f\u7684\u6d6a\u6f6e\u4e2d&#xff0c;Docker\u548cDocker Compose\u5982\u540c\u201c\u53cc\u5b50\u661f\u201d&#xff0c;\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u5355\u5175\u4f5c\u6218&#xff0c;\u4e00\u4e2a\u64c5\u957f\u519b\u56e2\u6307\u6325\u3002\u5b83\u4eec\u770b\u4f3c\u76f8\u4f3c&#xff0c;\u5374\u5404\u53f8\u5176\u804c\u3002\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4&#xff0c;\u7406\u89e3\u5b83\u4eec\u7684\u533a\u522b\u4e0d\u4ec5\u80fd\u8ba9\u4ee3\u7801\u90e8\u7f72\u4e8b\u534a\u529f\u500d&#xff0c;\u66f4\u80fd\u907f\u514d\u8e29\u5751\u3002\u672c\u6587\u5c06\u6df1\u5165\u6d45\u51fa\u5730\u89e3\u6790\u8fd9\u5bf9\u201c\u642d\u6863\u201d\u7684\u5f02\u540c&#xff0c;\u5e76\u9644\u4e0a\u5b9e\u6218\u6280\u5de7\u548c\u907f\u5751\u6307\u5357\u3002<\/p>\n<hr \/>\n<h4>\u4e00\u3001\u5b9a\u4e49&#xff1a;\u5355\u5175\u4e0e\u519b\u56e2\u7684\u201c\u8eab\u4efd\u5dee\u5f02\u201d<\/h4>\n<ul>\n<li>\n<p>Docker&#xff1a;<br \/>\nDocker\u662f\u4e00\u4e2a\u5bb9\u5668\u5316\u5e73\u53f0&#xff0c;\u5b83\u7684\u6838\u5fc3\u662f\u201c\u5bb9\u5668\u5f15\u64ce\u201d\u3002\u4f60\u53ef\u4ee5\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u201c\u96c6\u88c5\u7bb1\u5de5\u5382\u201d&#xff0c;\u8d1f\u8d23\u5c06\u5e94\u7528\u53ca\u5176\u4f9d\u8d56\u6253\u5305\u6210\u6807\u51c6\u5316\u7684\u5bb9\u5668&#xff08;Container&#xff09;&#xff0c;\u5e76\u5728\u4efb\u4f55\u652f\u6301Docker\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002<\/p>\n<ul>\n<li>\u6838\u5fc3\u529f\u80fd&#xff1a;\u6784\u5efa\u955c\u50cf&#xff08;Image&#xff09;\u3001\u8fd0\u884c\u5bb9\u5668\u3001\u7ba1\u7406\u5bb9\u5668\u751f\u547d\u5468\u671f\u3002<\/li>\n<li>\u5178\u578b\u547d\u4ee4&#xff1a;docker build, docker run, docker stop\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Docker Compose&#xff1a;<br \/>\nDocker Compose\u662f\u591a\u5bb9\u5668\u7f16\u6392\u5de5\u5177&#xff0c;\u5b83\u66f4\u50cf\u662f\u4e00\u4e2a\u201c\u6307\u6325\u5b98\u201d&#xff0c;\u901a\u8fc7YAML\u6587\u4ef6\u5b9a\u4e49\u591a\u4e2a\u5bb9\u5668\u7684\u534f\u4f5c\u65b9\u5f0f&#xff0c;\u4e00\u952e\u542f\u52a8\u6574\u4e2a\u5e94\u7528\u6808\u3002<\/p>\n<ul>\n<li>\u6838\u5fc3\u529f\u80fd&#xff1a;\u901a\u8fc7docker-compose.yml\u6587\u4ef6\u5b9a\u4e49\u670d\u52a1&#xff08;Service&#xff09;\u3001\u7f51\u7edc&#xff08;Network&#xff09;\u3001\u5377&#xff08;Volume&#xff09;&#xff0c;\u5e76\u81ea\u52a8\u5904\u7406\u5bb9\u5668\u95f4\u7684\u4f9d\u8d56\u548c\u8fde\u63a5\u3002<\/li>\n<li>\u5178\u578b\u547d\u4ee4&#xff1a;docker-compose up, docker-compose down\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u7c7b\u6bd4&#xff1a;<\/p>\n<ul>\n<li>Docker &#061; \u6218\u58eb&#xff1a;\u64c5\u957f\u72ec\u7acb\u4f5c\u6218&#xff0c;\u4f46\u9700\u8981\u624b\u52a8\u7ba1\u7406\u7ec6\u8282\u3002<\/li>\n<li>Docker Compose &#061; \u519b\u56e2\u6307\u6325\u5b98&#xff1a;\u64c5\u957f\u7edf\u7b79\u5168\u5c40&#xff0c;\u8ba9\u591a\u4e2a\u201c\u6218\u58eb\u201d\u534f\u540c\u4f5c\u6218\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u4e8c\u3001\u5e38\u89c1\u5c5e\u6027\u5bf9\u6bd4&#xff1a;\u4ece\u201c\u5355\u5175\u88c5\u5907\u201d\u5230\u201c\u519b\u56e2\u6218\u672f\u201d<\/h4>\n<table>\n<tr>\u7279\u6027DockerDocker Compose<\/tr>\n<tbody>\n<tr>\n<td>\u914d\u7f6e\u65b9\u5f0f<\/td>\n<td>\u547d\u4ee4\u884c\u53c2\u6570\u6216Dockerfile<\/td>\n<td>YAML\u6587\u4ef6&#xff08;\u58f0\u660e\u5f0f\u914d\u7f6e&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5bb9\u5668\u7ba1\u7406<\/td>\n<td>\u624b\u52a8\u7ba1\u7406\u5355\u4e2a\u5bb9\u5668<\/td>\n<td>\u81ea\u52a8\u7ba1\u7406\u591a\u4e2a\u5bb9\u5668\u53ca\u4f9d\u8d56\u5173\u7cfb<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc<\/td>\n<td>\u9ed8\u8ba4\u6865\u63a5\u7f51\u7edc&#xff08;\u9700\u624b\u52a8\u914d\u7f6e&#xff09;<\/td>\n<td>\u81ea\u52a8\u521b\u5efa\u5171\u4eab\u7f51\u7edc&#xff0c;\u670d\u52a1\u95f4\u901a\u8fc7\u540d\u79f0\u901a\u4fe1<\/td>\n<\/tr>\n<tr>\n<td>\u5377&#xff08;Volume&#xff09;<\/td>\n<td>\u624b\u52a8\u6302\u8f7d<\/td>\n<td>\u81ea\u52a8\u6302\u8f7d\u5171\u4eab\u5377<\/td>\n<\/tr>\n<tr>\n<td>\u542f\u52a8\u987a\u5e8f<\/td>\n<td>\u9700\u624b\u52a8\u63a7\u5236\u5bb9\u5668\u542f\u52a8\u987a\u5e8f<\/td>\n<td>\u901a\u8fc7depends_on\u81ea\u52a8\u7ba1\u7406\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>\u65e5\u5fd7\u7ba1\u7406<\/td>\n<td>docker logs\u67e5\u770b\u5355\u4e2a\u5bb9\u5668\u65e5\u5fd7<\/td>\n<td>docker-compose logs\u96c6\u4e2d\u67e5\u770b\u6240\u6709\u65e5\u5fd7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h4>\u4e09\u3001\u5e38\u7528\u65b9\u6cd5&#xff1a;\u4ece\u201c\u5355\u5175\u7a81\u51fb\u201d\u5230\u201c\u519b\u56e2\u51b2\u950b\u201d<\/h4>\n<h5>1. Docker\u7684\u5e38\u7528\u65b9\u6cd5<\/h5>\n<ul>\n<li>\u6784\u5efa\u955c\u50cf&#xff1a;<span class=\"token function\">docker<\/span> build <span class=\"token parameter variable\">-t<\/span> my-app <span class=\"token builtin class-name\">.<\/span>\n<\/li>\n<li>\u8fd0\u884c\u5bb9\u5668&#xff1a;<span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">8080<\/span>:80 my-app\n<\/li>\n<li>\u505c\u6b62\u5bb9\u5668&#xff1a;<span class=\"token function\">docker<\/span> stop <span class=\"token operator\">&lt;<\/span>container_id<span class=\"token operator\">&gt;<\/span>\n<\/li>\n<li>\u5220\u9664\u5bb9\u5668&#xff1a;<span class=\"token function\">docker<\/span> <span class=\"token function\">rm<\/span> <span class=\"token operator\">&lt;<\/span>container_id<span class=\"token operator\">&gt;<\/span>\n<\/li>\n<\/ul>\n<h5>2. Docker Compose\u7684\u5e38\u7528\u65b9\u6cd5<\/h5>\n<ul>\n<li>\u542f\u52a8\u670d\u52a1&#xff1a;<span class=\"token function\">docker-compose<\/span> up <span class=\"token parameter variable\">-d<\/span>\n<\/li>\n<li>\u505c\u6b62\u5e76\u5220\u9664\u670d\u52a1&#xff1a;<span class=\"token function\">docker-compose<\/span> down\n<\/li>\n<li>\u67e5\u770b\u670d\u52a1\u65e5\u5fd7&#xff1a;<span class=\"token function\">docker-compose<\/span> logs\n<\/li>\n<li>\u8fdb\u5165\u5bb9\u5668\u6267\u884c\u547d\u4ee4&#xff1a;<span class=\"token function\">docker-compose<\/span> <span class=\"token builtin class-name\">exec<\/span> <span class=\"token operator\">&lt;<\/span>service_name<span class=\"token operator\">&gt;<\/span> <span class=\"token function\">bash<\/span>\n<\/li>\n<\/ul>\n<hr \/>\n<h4>\u56db\u3001\u5b9e\u6218\u573a\u666f&#xff1a;\u4f55\u65f6\u7528Docker&#xff1f;\u4f55\u65f6\u7528Docker Compose&#xff1f;<\/h4>\n<h5>\u9002\u5408Docker\u7684\u573a\u666f<\/h5>\n<li>\u5355\u670d\u52a1\u90e8\u7f72&#xff1a;\u4f8b\u5982\u90e8\u7f72\u4e00\u4e2a\u7b80\u5355\u7684Web\u5e94\u7528&#xff08;\u5982Nginx&#xff09;\u3002<span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">80<\/span>:80 nginx\n<\/li>\n<li>\u5feb\u901f\u6d4b\u8bd5&#xff1a;\u9700\u8981\u5feb\u901f\u542f\u52a8\u4e00\u4e2a\u4e34\u65f6\u5bb9\u5668\u8fdb\u884c\u6d4b\u8bd5\u65f6\u3002<\/li>\n<li>\u7cbe\u7ec6\u63a7\u5236&#xff1a;\u9700\u8981\u624b\u52a8\u8c03\u6574\u5bb9\u5668\u914d\u7f6e&#xff08;\u5982\u7f51\u7edc\u3001\u7aef\u53e3\u6620\u5c04&#xff09;\u3002<\/li>\n<h5>\u9002\u5408Docker Compose\u7684\u573a\u666f<\/h5>\n<li>\u591a\u670d\u52a1\u5e94\u7528&#xff1a;\u4f8b\u5982\u4e00\u4e2a\u5305\u542b\u524d\u7aef\u3001\u540e\u7aef\u548c\u6570\u636e\u5e93\u7684\u5fae\u670d\u52a1\u67b6\u6784\u3002<span class=\"token key atrule\">version<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;3&#039;<\/span><br \/>\n<span class=\"token key atrule\">services<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">web<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">image<\/span><span class=\"token punctuation\">:<\/span> nginx<br \/>\n    <span class=\"token key atrule\">ports<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;80:80&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n  <span class=\"token key atrule\">db<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">image<\/span><span class=\"token punctuation\">:<\/span> mysql<br \/>\n    <span class=\"token key atrule\">environment<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token key atrule\">MYSQL_ROOT_PASSWORD<\/span><span class=\"token punctuation\">:<\/span> root<\/p>\n<\/li>\n<li>\u5f00\u53d1\u73af\u5883\u4e00\u81f4\u6027&#xff1a;\u901a\u8fc7docker-compose.yml\u5feb\u901f\u590d\u5236\u5f00\u53d1\u73af\u5883\u3002<\/li>\n<li>\u4e00\u952e\u90e8\u7f72&#xff1a;\u5728CI\/CD\u6d41\u6c34\u7ebf\u4e2d\u4e00\u952e\u542f\u52a8\u6574\u4e2a\u5e94\u7528\u6808\u3002<\/li>\n<hr \/>\n<h4>\u4e94\u3001\u4f7f\u7528\u6280\u5de7&#xff1a;\u4ece\u201c\u83dc\u9e1f\u201d\u5230\u201c\u9ad8\u624b\u201d\u7684\u8fdb\u9636\u6307\u5357<\/h4>\n<h5>1. Docker\u7684\u4f7f\u7528\u6280\u5de7<\/h5>\n<ul>\n<li>\u4f18\u5316Dockerfile&#xff1a;\n<ul>\n<li>\u5408\u5e76\u591a\u6761RUN\u6307\u4ee4&#xff0c;\u51cf\u5c11\u955c\u50cf\u5c42\u6570\u3002<\/li>\n<li>\u4f7f\u7528.dockerignore\u6587\u4ef6\u6392\u9664\u65e0\u5173\u6587\u4ef6&#xff0c;\u52a0\u5feb\u6784\u5efa\u901f\u5ea6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5171\u4eab\u7f51\u7edc&#xff1a;<br \/>\n\u901a\u8fc7&#8211;network\u53c2\u6570\u624b\u52a8\u521b\u5efa\u5171\u4eab\u7f51\u7edc&#xff0c;\u5b9e\u73b0\u5bb9\u5668\u95f4\u901a\u4fe1\u3002<span class=\"token function\">docker<\/span> network create my-network<br \/>\n<span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">&#8211;network<\/span> my-network my-app<\/p>\n<\/li>\n<\/ul>\n<h5>2. Docker Compose\u7684\u4f7f\u7528\u6280\u5de7<\/h5>\n<ul>\n<li>\u73af\u5883\u53d8\u91cf\u7ba1\u7406&#xff1a;<br \/>\n\u4f7f\u7528.env\u6587\u4ef6\u7ba1\u7406\u654f\u611f\u4fe1\u606f&#xff08;\u5982\u5bc6\u7801&#xff09;&#xff0c;\u907f\u514d\u786c\u7f16\u7801\u3002<span class=\"token key atrule\">environment<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">DB_PASSWORD<\/span><span class=\"token punctuation\">:<\/span> $<span class=\"token punctuation\">{<\/span>DB_PASSWORD<span class=\"token punctuation\">}<\/span><\/p>\n<\/li>\n<li>\u670d\u52a1\u6269\u5c55&#xff1a;<br \/>\n\u901a\u8fc7&#8211;scale\u53c2\u6570\u6a2a\u5411\u6269\u5c55\u670d\u52a1\u5b9e\u4f8b\u3002<span class=\"token function\">docker-compose<\/span> up <span class=\"token parameter variable\">-d<\/span> <span class=\"token parameter variable\">&#8211;scale<\/span> <span class=\"token assign-left variable\">web<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><\/p>\n<\/li>\n<li>\u70ed\u66f4\u65b0&#xff1a;<br \/>\n\u4fee\u6539\u4ee3\u7801\u540e&#xff0c;\u4f7f\u7528docker-compose restart\u91cd\u542f\u670d\u52a1&#xff08;\u6ce8\u610f&#xff1a;\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u9700\u5148down\u518dup&#xff09;\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u516d\u3001\u6ce8\u610f\u4e8b\u9879&#xff1a;\u907f\u514d\u8e29\u5751\u7684\u201c\u8840\u6cea\u6559\u8bad\u201d<\/h4>\n<li>\n<p>Docker Compose\u7684\u9677\u9631&#xff1a;<\/p>\n<ul>\n<li>depends_on\u4e0d\u7b49\u4e8e\u7b49\u5f85\u5c31\u7eea&#xff1a;<br \/>\ndepends_on\u4ec5\u4fdd\u8bc1\u5bb9\u5668\u542f\u52a8\u987a\u5e8f&#xff0c;\u4e0d\u7b49\u5f85\u670d\u52a1\u5b8c\u5168\u5c31\u7eea\u3002\u5efa\u8bae\u7ed3\u5408\u5065\u5eb7\u68c0\u67e5&#xff08;healthcheck&#xff09;\u4f7f\u7528\u3002<\/li>\n<li>\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u9700\u91cd\u5efa&#xff1a;<br \/>\n\u4fee\u6539docker-compose.yml\u540e&#xff0c;\u9700\u6267\u884cdocker-compose down\u518dup&#xff0c;\u5426\u5219\u914d\u7f6e\u4e0d\u4f1a\u751f\u6548\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Docker\u7684\u5e38\u89c1\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u5bb9\u5668\u9000\u51fa\u5373\u505c\u6b62&#xff1a;<br \/>\n\u5982\u679c\u5bb9\u5668\u542f\u52a8\u540e\u7acb\u5373\u9000\u51fa&#xff0c;\u68c0\u67e5\u5e94\u7528\u662f\u5426\u5728\u524d\u53f0\u8fd0\u884c&#xff08;\u5982\u907f\u514dCMD [&#034;nginx&#034;]\u800c\u5e94\u4f7f\u7528CMD [&#034;nginx&#034;, &#034;-g&#034;, &#034;daemon off;&#034;]&#xff09;\u3002<\/li>\n<li>\u8d44\u6e90\u9650\u5236&#xff1a;<br \/>\n\u5bb9\u5668\u9ed8\u8ba4\u65e0\u8d44\u6e90\u9650\u5236&#xff0c;\u9700\u901a\u8fc7&#8211;memory\u6216&#8211;cpus\u53c2\u6570\u63a7\u5236\u8d44\u6e90\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>\u4e03\u3001\u603b\u7ed3&#xff1a;\u9009\u62e9\u5de5\u5177&#xff0c;\u800c\u975e\u76f2\u76ee\u8ddf\u98ce<\/h4>\n<ul>\n<li>Docker&#xff1a;\u9002\u5408\u8f7b\u91cf\u7ea7\u4efb\u52a1\u548c\u5bf9\u5bb9\u5668\u6709\u7cbe\u7ec6\u63a7\u5236\u9700\u6c42\u7684\u573a\u666f\u3002<\/li>\n<li>Docker Compose&#xff1a;\u9002\u5408\u9700\u8981\u591a\u5bb9\u5668\u534f\u4f5c\u7684\u590d\u6742\u5e94\u7528&#xff08;\u5982\u5fae\u670d\u52a1\u3001\u5f00\u53d1\u73af\u5883&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u7ec8\u6781\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u5982\u679c\u4f60\u7684\u9879\u76ee\u53ea\u6709\u5355\u4e2a\u670d\u52a1&#xff0c;Docker\u8db3\u4ee5\u5e94\u5bf9\u3002<\/li>\n<li>\u5982\u679c\u4f60\u7684\u9879\u76ee\u6d89\u53ca\u591a\u4e2a\u670d\u52a1&#xff08;\u5982Web &#043; DB &#043; Cache&#xff09;&#xff0c;Docker Compose\u662f\u66f4\u9ad8\u6548\u7684\u9009\u62e9\u3002<\/li>\n<\/ul>\n<p>\u8bb0\u4f4f&#xff1a;\u5de5\u5177\u6ca1\u6709\u7edd\u5bf9\u4f18\u52a3&#xff0c;\u53ea\u6709\u201c\u5408\u9002\u4e0e\u5426\u201d\u3002\u638c\u63e1\u5b83\u4eec\u7684\u533a\u522b&#xff0c;\u624d\u80fd\u5728\u5bb9\u5668\u5316\u7684\u6218\u573a\u4e0a\u201c\u5982\u9c7c\u5f97\u6c34\u201d&#xff01;<\/p>\n<hr \/>\n<p>\u7ed3\u8bed&#xff1a;<br \/>\nDocker\u548cDocker Compose\u5982\u540c\u201c\u77db\u4e0e\u76fe\u201d&#xff0c;\u524d\u8005\u662f\u57fa\u7840&#xff0c;\u540e\u8005\u662f\u8fdb\u9636\u3002\u7406\u89e3\u5b83\u4eec\u7684\u5dee\u5f02&#xff0c;\u4e0d\u4ec5\u80fd\u63d0\u5347\u5f00\u53d1\u6548\u7387&#xff0c;\u8fd8\u80fd\u8ba9\u4f60\u7684\u90e8\u7f72\u6d41\u7a0b\u66f4\u52a0\u4f18\u96c5\u3002\u4e0b\u6b21\u5f53\u4f60\u9762\u5bf9\u590d\u6742\u7684\u5bb9\u5668\u5316\u9700\u6c42\u65f6&#xff0c;\u4e0d\u59a8\u95ee\u81ea\u5df1\u4e00\u53e5&#xff1a;\u201c\u8fd9\u662f\u5355\u5175\u4f5c\u6218&#xff0c;\u8fd8\u662f\u9700\u8981\u519b\u56e2\u51b2\u950b&#xff1f;\u201d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb77\u6b21\u3002\u5728\u5bb9\u5668\u5316\u6280\u672f\u7684\u6d6a\u6f6e\u4e2d\uff0cDocker\u548cDocker Compose\u5982\u540c\u201c\u53cc\u5b50\u661f\u201d\uff0c\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u5355\u5175\u4f5c\u6218\uff0c\u4e00\u4e2a\u64c5\u957f\u519b\u56e2\u6307\u6325\u3002Docker\u548cDocker Compose\u5982\u540c\u201c\u77db\u4e0e\u76fe\u201d\uff0c\u524d\u8005\u662f\u57fa\u7840\uff0c\u540e\u8005\u662f\u8fdb\u9636\u3002\u7406\u89e3\u5b83\u4eec\u7684\u5dee\u5f02\uff0c\u4e0d\u4ec5\u80fd\u63d0\u5347\u5f00\u53d1\u6548\u7387\uff0c\u8fd8\u80fd\u8ba9\u4f60\u7684\u90e8\u7f72\u6d41\u7a0b\u66f4\u52a0\u4f18\u96c5\u3002\uff0c\u5b83\u7684\u6838\u5fc3\u662f\u201c\u5bb9\u5668\u5f15\u64ce\u201d\u3002\u4f60\u53ef\u4ee5\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u201c\u96c6\u88c5\u7bb1\u5de5\u5382\u201d\uff0c\u8d1f\u8d23\u5c06\u5e94\u7528\u53ca\u5176\u4f9d\u8d56\u6253\u5305\u6210\u6807\u51c6\u5316\u7684\u5bb9\u5668\uff08Container\uff09\uff0c\u5e76\u5728\u4efb\u4f55\u652f\u6301Docker\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002\uff0c\u5b83\u66f4\u50cf\u662f\u4e00\u4e2a\u201c\u6307\u6325\u5b98\u201d\uff0c\u901a\u8fc7YAML\u6587\u4ef6\u5b9a\u4e49\u591a\u4e2a\u5bb9\u5668\u7684\u534f\u4f5c\u65b9\u5f0f\uff0c\u4e00\u952e\u542f\u52a8\u6574\u4e2a\u5e94\u7528\u6808\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,838,121],"topic":[],"class_list":["post-54873","post","type-post","status-publish","format-standard","hentry","category-server","tag-docker","tag-eureka","tag-121"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d - \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\/54873.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb77\u6b21\u3002\u5728\u5bb9\u5668\u5316\u6280\u672f\u7684\u6d6a\u6f6e\u4e2d\uff0cDocker\u548cDocker Compose\u5982\u540c\u201c\u53cc\u5b50\u661f\u201d\uff0c\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u5355\u5175\u4f5c\u6218\uff0c\u4e00\u4e2a\u64c5\u957f\u519b\u56e2\u6307\u6325\u3002Docker\u548cDocker Compose\u5982\u540c\u201c\u77db\u4e0e\u76fe\u201d\uff0c\u524d\u8005\u662f\u57fa\u7840\uff0c\u540e\u8005\u662f\u8fdb\u9636\u3002\u7406\u89e3\u5b83\u4eec\u7684\u5dee\u5f02\uff0c\u4e0d\u4ec5\u80fd\u63d0\u5347\u5f00\u53d1\u6548\u7387\uff0c\u8fd8\u80fd\u8ba9\u4f60\u7684\u90e8\u7f72\u6d41\u7a0b\u66f4\u52a0\u4f18\u96c5\u3002\uff0c\u5b83\u7684\u6838\u5fc3\u662f\u201c\u5bb9\u5668\u5f15\u64ce\u201d\u3002\u4f60\u53ef\u4ee5\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u201c\u96c6\u88c5\u7bb1\u5de5\u5382\u201d\uff0c\u8d1f\u8d23\u5c06\u5e94\u7528\u53ca\u5176\u4f9d\u8d56\u6253\u5305\u6210\u6807\u51c6\u5316\u7684\u5bb9\u5668\uff08Container\uff09\uff0c\u5e76\u5728\u4efb\u4f55\u652f\u6301Docker\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002\uff0c\u5b83\u66f4\u50cf\u662f\u4e00\u4e2a\u201c\u6307\u6325\u5b98\u201d\uff0c\u901a\u8fc7YAML\u6587\u4ef6\u5b9a\u4e49\u591a\u4e2a\u5bb9\u5668\u7684\u534f\u4f5c\u65b9\u5f0f\uff0c\u4e00\u952e\u542f\u52a8\u6574\u4e2a\u5e94\u7528\u6808\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54873.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-13T04:19:49+00:00\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54873.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54873.html\",\"name\":\"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-13T04:19:49+00:00\",\"dateModified\":\"2025-08-13T04:19:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54873.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54873.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54873.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d\"}]},{\"@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\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d - \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\/54873.html","og_locale":"zh_CN","og_type":"article","og_title":"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb77\u6b21\u3002\u5728\u5bb9\u5668\u5316\u6280\u672f\u7684\u6d6a\u6f6e\u4e2d\uff0cDocker\u548cDocker Compose\u5982\u540c\u201c\u53cc\u5b50\u661f\u201d\uff0c\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u5355\u5175\u4f5c\u6218\uff0c\u4e00\u4e2a\u64c5\u957f\u519b\u56e2\u6307\u6325\u3002Docker\u548cDocker Compose\u5982\u540c\u201c\u77db\u4e0e\u76fe\u201d\uff0c\u524d\u8005\u662f\u57fa\u7840\uff0c\u540e\u8005\u662f\u8fdb\u9636\u3002\u7406\u89e3\u5b83\u4eec\u7684\u5dee\u5f02\uff0c\u4e0d\u4ec5\u80fd\u63d0\u5347\u5f00\u53d1\u6548\u7387\uff0c\u8fd8\u80fd\u8ba9\u4f60\u7684\u90e8\u7f72\u6d41\u7a0b\u66f4\u52a0\u4f18\u96c5\u3002\uff0c\u5b83\u7684\u6838\u5fc3\u662f\u201c\u5bb9\u5668\u5f15\u64ce\u201d\u3002\u4f60\u53ef\u4ee5\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u201c\u96c6\u88c5\u7bb1\u5de5\u5382\u201d\uff0c\u8d1f\u8d23\u5c06\u5e94\u7528\u53ca\u5176\u4f9d\u8d56\u6253\u5305\u6210\u6807\u51c6\u5316\u7684\u5bb9\u5668\uff08Container\uff09\uff0c\u5e76\u5728\u4efb\u4f55\u652f\u6301Docker\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002\uff0c\u5b83\u66f4\u50cf\u662f\u4e00\u4e2a\u201c\u6307\u6325\u5b98\u201d\uff0c\u901a\u8fc7YAML\u6587\u4ef6\u5b9a\u4e49\u591a\u4e2a\u5bb9\u5668\u7684\u534f\u4f5c\u65b9\u5f0f\uff0c\u4e00\u952e\u542f\u52a8\u6574\u4e2a\u5e94\u7528\u6808\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/54873.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-13T04:19:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54873.html","url":"https:\/\/www.wsisp.com\/helps\/54873.html","name":"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-13T04:19:49+00:00","dateModified":"2025-08-13T04:19:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54873.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54873.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54873.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Docker\u4e0eDocker Compose\uff1a\u5bb9\u5668\u4e16\u754c\u7684\u201c\u5355\u5175\u4f5c\u6218\u201d\u4e0e\u201c\u519b\u56e2\u6307\u6325\u5b98\u201d"}]},{"@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\/54873","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=54873"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54873\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54873"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}