{"id":2166,"date":"2025-06-27T12:04:01","date_gmt":"2025-06-27T04:04:01","guid":{"rendered":"https:\/\/www.madbull.site\/?p=2166"},"modified":"2025-06-27T13:59:52","modified_gmt":"2025-06-27T05:59:52","slug":"docker-compose%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/www.madbull.site\/?p=2166","title":{"rendered":"docker-compose\u914d\u7f6e\u6587\u4ef6\u89e3\u6790"},"content":{"rendered":"\n<p>\u6211\u4eec\u5728\u628a\u670d\u52a1docker\u5316\u7684\u65f6\u5019\uff0c\u4e0d\u4ec5\u9700\u8981\u628a\u5404\u4e2a\u670d\u52a1\u505a\u6210docker\u955c\u50cf\uff0c\u8fd8\u9700\u8981\u7f16\u8f91\u5404\u4e2a\u670d\u52a1\u4e4b\u95f4\u7684\u542f\u52a8\u65b9\u5f0f\u3002\u5bf9\u4e8e\u4e0d\u9700\u8981\u66b4\u9732\u7684\u7aef\u53e3\uff0c\u8fd8\u9700\u8981\u901a\u8fc7\u865a\u62df\u7f51\u6865\u7684\u65b9\u5f0f\uff0c\u4fdd\u8bc1\u5404\u4e2a\u670d\u52a1\u4e4b\u95f4\u7684\u6b63\u5e38\u901a\u8baf\u3002\u8fd9\u5c31\u9700\u8981\u7528\u5230 docker-compose \u5de5\u5177\uff0c\u5e76\u4e14\u9700\u8981\u7f16\u8f91\u5bf9\u5e94\u7684 Docker Compose \u914d\u7f6e\u6587\u4ef6\u6765\u63a7\u5236\u542f\u52a8\u3002<\/p>\n\n\n\n<div style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);height:0px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Docker Compose\u914d\u7f6e\u6587\u4ef6\u662f\u4e00\u4e2aYAML\u683c\u5f0f\u7684\u6587\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u547d\u540d\u4e3a <strong>docker-compose.yml<\/strong> \u6216\u8005 <strong>compose.yml<\/strong> \u3002\u5b83\u5b9a\u4e49\u4e86\u591a\u4e2a\u5bb9\u5668\u5e94\u7528\u7684\u670d\u52a1\u3001\u7f51\u7edc\u548c\u5377\u7b49\u7ec6\u8282\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u547d\u4ee4\u8f7b\u677e\u7ba1\u7406\u591a\u5bb9\u5668Docker\u5e94\u7528\u7684\u751f\u547d\u5468\u671f\u3002\u901a\u8fc7\u8be5\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u63cf\u8ff0\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u670d\u52a1\uff08\u5982Web\u670d\u52a1\u5668\u3001\u6570\u636e\u5e93\u7b49\uff09\uff0c\u6bcf\u4e2a\u670d\u52a1\u8fd0\u884c\u7684\u955c\u50cf\u3001\u7aef\u53e3\u6620\u5c04\u3001\u4f9d\u8d56\u5173\u7cfb\u3001\u73af\u5883\u53d8\u91cf\u3001\u5b58\u50a8\u5377\u7b49\u4fe1\u606f\u3002<\/p>\n\n\n\n<div style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);height:0px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>\u4eca\u5929\u5c31\u62ff\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\u7684 compose.yml \u6587\u4ef6 \u5206\u4eab\u4e00\u4e0b\u7f16\u5199\u683c\u5f0f\u3002<\/p>\n\n\n\n<div style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);height:0px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>x-logging: &amp;default-logging\n  driver: \"json-file\"\n  options:\n    max-size: \"10m\"\n    max-file: \"10\"\n\nnetworks:\n  playedu:\n    driver: bridge\n\nvolumes:\n  mysql-data:\n\nservices:\n  playedu:\n    image: registry.cn-hangzhou.aliyuncs.com\/playedu\/light:2.0\n    restart: always\n    environment:\n      - DB_HOST=mysql\n      - DB_PORT=3306\n      - DB_NAME=playedu\n      - DB_USER=root\n      - DB_PASS=playeduxyz\n      - SA_TOKEN_IS_CONCURRENT=false\n      - SA_TOKEN_JWT_SECRET_KEY=${PLAYEDU_JWT_KEY:-playeduxyz}\n    ports:\n      - \"${PLAYEDU_API_PORT:-9700}:9898\"\n      - \"${PLAYEDU_PC_PORT:-9800}:9800\"\n      - \"${PLAYEDU_H5_PORT:-9801}:9801\"\n      - \"${PLAYEDU_ADMIN_PORT:-9900}:9900\"\n    networks:\n      - playedu\n    depends_on:\n      - mysql\n    logging: *default-logging\n\n  mysql:\n    build: .\/docker\/mysql\n    restart: always\n    environment:\n      - MYSQL_DATABASE=playedu\n      - MYSQL_ROOT_PASSWORD=playeduxyz\n      - TZ=UTC\n    volumes:\n      - mysql-data:\/var\/lib\/mysql\n    ports:\n      - \"${MYSQL_PORT:-23307}:3306\"\n    networks:\n      - playedu\n    logging: *default-logging<\/code><\/pre>\n\n\n\n<div style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);height:0px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>x-logging: &amp;default-logging     \u5b9a\u4e49\u4e00\u4e2a\u65e5\u5fd7\u8bb0\u5f55\u6a21\u677f\uff0c\u540d\u5b57\u662f\uff1adefault-logging\n<ul class=\"wp-block-list\">\n<li>driver: &#8220;json-file&#8221;      Docker \u5bb9\u5668\u4f7f\u7528\u7684\u65e5\u5fd7\u9a71\u52a8\u4e3a&nbsp;<code>json-file<\/code>\uff0c\u5373\u5c06\u5bb9\u5668\u7684\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u8bb0\u5f55\u5230 JSON \u683c\u5f0f\u7684\u6587\u4ef6\u4e2d\u3002<\/li>\n\n\n\n<li>  options:       \u5b9a\u4e49\u53c2\u6570\uff0c\u65e5\u5fd7\u6587\u4ef6\u6700\u5927 10MB\uff0c\u8d85\u8fc7\u8be5\u5927\u5c0f\u540e\u4f1a\u81ea\u52a8\u8fdb\u884c\u65e5\u5fd7\u8f6e\u8f6c\u3002\u6700\u591a10\u4e2a\u65e7\u6587\u4ef6\u3002<br>    max-size: &#8220;10m&#8221;<br>    max-file: &#8220;10&#8221;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>networks:    \u5b9a\u4e49\u865a\u62df\u7f51\u7edc\uff0c\u540d\u5b57\u662f playedu\uff0c\u6a21\u5f0f\u662fbridge\uff08\u6865\uff09<br>  playedu:<br>    driver: bridge<\/li>\n\n\n\n<li>volumes:     \u5b9a\u4e49\u5377\uff08\u5b58\u50a8\u7528\u7684\uff09\uff0c\u540d\u79f0\u662f mysql-data\u3002\u8fd9\u91cc\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2a\u3002<br>  mysql-data:<\/li>\n\n\n\n<li>services:     \u8fd9\u91cc\u5b9a\u4e49\u7684\u662f\u670d\u52a1\u7684\u90e8\u5206\n<ul class=\"wp-block-list\">\n<li>  playedu:    \u670d\u52a1\u540d\u79f0\uff0c\u4e5f\u7528\u4f5c\u4e3b\u673a\u540d\uff0c\u901a\u8fc7\u865a\u62df\u7f51\u7edc\u8bbf\u95ee\u8bbf\u95ee\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u6b64\u4e3b\u673a\u3002\n<ul class=\"wp-block-list\">\n<li>image:        \u6307\u5b9a\u4f7f\u7528\u54ea\u4e2a\u955c\u50cf<\/li>\n\n\n\n<li>build: \u6307\u5b9a\u955c\u50cf\u5236\u4f5c\u7684\u76ee\u5f55\u3002\u5982\u679c\u6307\u5b9a\u7684\u955c\u50cf\u4e0d\u5b58\u5728\uff0c\u5219\u81ea\u52a8\u4f1a\u5230\u6b64\u76ee\u5f55\uff0c\u67e5\u627eDockerfile\u6587\u4ef6\uff0c\u5e76\u521b\u5efa\u955c\u50cf\u3002<\/li>\n\n\n\n<li>restart:       \u542f\u52a8\u65b9\u5f0f\uff0c\u914d\u7f6ealways\uff0c\u5728\u76d1\u63a7\u5230\u670d\u52a1down\u4e4b\u540e\uff0c\u81ea\u52a8\u542f\u52a8\u3002<\/li>\n\n\n\n<li>environment:    \u4ee5\u6765\u7684\u73af\u5883\u53d8\u91cf\u3002\u8fd9\u4e9b\u53d8\u91cf\uff0c\u5728\u955c\u50cf\u521d\u59cb\u5316\u6216\u8005\u8fd0\u884c\u7684\u65f6\u5019\uff0c\u4f1a\u7528\u5230\u8fd9\u4e9b\u53d8\u91cf\u3002<\/li>\n\n\n\n<li>ports:         \u7aef\u53e3\u6620\u5c04\uff0c\u628a\u5bb9\u5668\u5185\u90e8\u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u3002<\/li>\n\n\n\n<li>networks:    \u5bb9\u5668\u4e4b\u95f4\u901a\u8baf\u4f7f\u7528\u7684\u7f51\u7edc\u3002<\/li>\n\n\n\n<li>depends_on:    \u542f\u52a8\u4f9d\u8d56\uff0c\u7528\u6765\u6392\u5e03\u542f\u52a8\u987a\u5e8f\u3002<\/li>\n\n\n\n<li>logging:       \u4f7f\u7528\u7684\u65e5\u5fd7\u6a21\u677f\u3002<\/li>\n\n\n\n<li>volumes:     \u5377\u6302\u8f7d\uff0c\u628a\u6307\u5b9a\u7684\u5377\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u90e8\u6307\u5b9a\u76ee\u5f55\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);height:0px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f compose.yml \u914d\u7f6e\u6587\u4ef6\u7684\u4e3b\u8981\u914d\u7f6e\u9879\u3002<\/p>\n\n\n\n<p>\u5173\u4e8edocker-compose \u57fa\u672c\u64cd\u4f5c\uff0c\u53c2\u8003\u5f80\u671f\u6587\u7ae0\uff1a<a href=\"https:\/\/www.madbull.site\/?p=2092\">https:\/\/www.madbull.site\/?p=2092<\/a> \u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker Compose\u914d\u7f6e\u6587\u4ef6\u662f\u4e00\u4e2aYAML\u683c\u5f0f\u7684\u6587\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u547d\u540d\u4e3a docker-compose.yml \u6216\u8005 compose.yml \u3002\u5b83\u5b9a\u4e49\u4e86\u591a\u4e2a\u5bb9\u5668\u5e94\u7528\u7684\u670d\u52a1\u3001\u7f51\u7edc\u548c\u5377\u7b49\u7ec6\u8282\uff0c\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u547d\u4ee4\u8f7b\u677e\u7ba1\u7406\u591a\u5bb9\u5668Docker\u5e94\u7528\u7684\u751f\u547d\u5468\u671f\u3002\u901a\u8fc7\u8be5\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u63cf\u8ff0\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u670d\u52a1\uff08\u5982Web\u670d\u52a1\u5668\u3001\u6570\u636e\u5e93\u7b49\uff09\uff0c\u6bcf\u4e2a\u670d\u52a1\u8fd0\u884c\u7684\u955c\u50cf\u3001\u7aef\u53e3\u6620\u5c04\u3001\u4f9d\u8d56\u5173\u7cfb\u3001\u73af\u5883\u53d8\u91cf\u3001\u5b58\u50a8\u5377\u7b49\u4fe1\u606f\u3002<\/p>\n","protected":false},"author":1,"featured_media":1044,"comment_status":"open","ping_status":"open","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"footnotes":""},"categories":[166,131,154],"tags":[669,145,670],"class_list":["post-2166","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tools","category-131","category-154","tag-compose","tag-docker","tag-670"],"_links":{"self":[{"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/posts\/2166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.madbull.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2166"}],"version-history":[{"count":4,"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/posts\/2166\/revisions"}],"predecessor-version":[{"id":2170,"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/posts\/2166\/revisions\/2170"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.madbull.site\/index.php?rest_route=\/wp\/v2\/media\/1044"}],"wp:attachment":[{"href":"https:\/\/www.madbull.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.madbull.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.madbull.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}