{"id":2850,"date":"2025-11-02T20:25:27","date_gmt":"2025-11-02T12:25:27","guid":{"rendered":"https:\/\/linuxjk.cn\/?p=2850"},"modified":"2026-01-21T13:10:55","modified_gmt":"2026-01-21T05:10:55","slug":"docker-compose%e5%ae%89%e8%a3%85%e6%96%87%e6%a1%a3","status":"publish","type":"post","link":"https:\/\/linuxjk.cn\/?p=2850","title":{"rendered":"docker-compose\u5b89\u88c5\u6587\u6863"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2850\" class=\"elementor elementor-2850\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6793fcc e-flex e-con-boxed e-con e-parent\" data-id=\"6793fcc\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-4014d7a elementor-widget elementor-widget-text-editor\" data-id=\"4014d7a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%96%B9%E6%A1%88%E4%B8%80%EF%BC%9A%E7%9B%B4%E6%8E%A5%E4%B8%8B%E8%BD%BD%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6\" >\u65b9\u6848\u4e00\uff1a\u76f4\u63a5\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#docker%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%85%E4%B8%8B%E8%BD%BD%EF%BC%9A\" >docker\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\uff1a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%96%B9%E6%A1%88%E4%BA%8C%EF%BC%9A%E4%BD%BF%E7%94%A8_Docker_%E5%AE%98%E6%96%B9%E4%BB%93%E5%BA%93%E5%AE%89%E8%A3%85\" >\u65b9\u6848\u4e8c\uff1a\u4f7f\u7528 Docker \u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E5%AE%89%E8%A3%85docker%E4%B9%8B%E5%90%8E%E9%85%8D%E7%BD%AEdocker%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E4%BD%8D%E7%BD%AE%EF%BC%9A\" >\u5b89\u88c5docker\u4e4b\u540e\u914d\u7f6edocker\u6570\u636e\u5b58\u50a8\u4f4d\u7f6e\uff1a<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%96%B9%E6%B3%951%EF%BC%9A_%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\" >\u65b9\u6cd51\uff1a \u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%96%B9%E6%B3%952%EF%BC%9A_%E4%BF%AE%E6%94%B9%E5%90%AF%E5%8A%A8%E9%80%89%E9%A1%B9\" >\u65b9\u6cd52\uff1a \u4fee\u6539\u542f\u52a8\u9009\u9879<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E9%85%8D%E7%BD%AE%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91\" >\u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E5%90%AF%E5%8A%A8%E6%B5%8B%E8%AF%95\" >\u542f\u52a8\u6d4b\u8bd5<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E6%96%B9%E6%A1%88%E4%B8%80%EF%BC%9A%E7%9B%B4%E6%8E%A5%E4%B8%8B%E8%BD%BD%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6\"><\/span>\u65b9\u6848\u4e00\uff1a\u76f4\u63a5\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2><p># 1. \u4e0b\u8f7d\u6700\u65b0\u7248 docker-compose<br \/><code>curl -L \"https:\/\/github.com\/docker\/compose\/releases\/latest\/download\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose<\/code><br \/><code>curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/v2.24.1\/docker-compose-Linux-x86_64\" -o \/usr\/local\/bin\/docker-compose<\/code><\/p><p># 2. \u6dfb\u52a0\u6267\u884c\u6743\u9650<br \/><code>chmod +x \/usr\/local\/bin\/docker-compose<\/code><\/p><p># 3. \u521b\u5efa\u8f6f\u94fe\u63a5\uff08\u53ef\u9009\uff09<br \/><code>ln -s \/usr\/local\/bin\/docker-compose \/usr\/bin\/docker-compose<\/code><\/p><p># 4. \u9a8c\u8bc1\u5b89\u88c5<br \/><code>docker compose version<\/code><\/p><h2><span class=\"ez-toc-section\" id=\"docker%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%85%E4%B8%8B%E8%BD%BD%EF%BC%9A\"><\/span>docker\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\uff1a<span class=\"ez-toc-section-end\"><\/span><\/h2><p><code>wget https:\/\/download.docker.com\/linux\/static\/stable\/x86_64\/docker-29.0.4.tgz<\/code><\/p><h2 class=\"md-end-block md-heading md-focus\"><span class=\"ez-toc-section\" id=\"%E6%96%B9%E6%A1%88%E4%BA%8C%EF%BC%9A%E4%BD%BF%E7%94%A8_Docker_%E5%AE%98%E6%96%B9%E4%BB%93%E5%BA%93%E5%AE%89%E8%A3%85\"><\/span><span class=\"md-plain md-expand\">\u65b9\u6848\u4e8c\uff1a\u4f7f\u7528 Docker \u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><p># 1. \u6dfb\u52a0 Docker \u5b98\u65b9\u4ed3\u5e93<br \/><code>yum install -y yum-utils<\/code><br \/><code>yum-config-manager --add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo<\/code><\/p><p>#\u66ff\u6362yum\u6e90\u5730\u5740<\/p><p><code>sed -i 's+https:\/\/download.docker.com+https:\/\/mirrors.tuna.tsinghua.edu.cn\/docker-ce+' \/etc\/yum.repos.d\/docker-ce.repo<\/code><\/p><p>\u6216\u8005\u76f4\u63a5\u4f7f\u7528\u56fd\u5185\u5730\u5740\uff1a<\/p><p><code>yum-config-manager --add-repo http:\/\/mirrors.ustc.edu.cn\/docker-ce\/linux\/centos\/docker-ce.repo<\/code><\/p><p># 2. \u5b89\u88c5 docker\/containerd\/docker-compose-plugin\uff08\u65b0\u7248\u672c\u65b9\u5f0f\uff09<br \/><code>yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin<\/code><\/p><p># 3. \u4f7f\u7528\u65b0\u547d\u4ee4<br \/><code>docker compose version<\/code><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-47e260c e-flex e-con-boxed e-con e-parent\" data-id=\"47e260c\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-bfcca1e elementor-widget elementor-widget-text-editor\" data-id=\"bfcca1e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2><span class=\"ez-toc-section\" id=\"%E5%AE%89%E8%A3%85docker%E4%B9%8B%E5%90%8E%E9%85%8D%E7%BD%AEdocker%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E4%BD%8D%E7%BD%AE%EF%BC%9A\"><\/span>\u5b89\u88c5docker\u4e4b\u540e\u914d\u7f6edocker\u6570\u636e\u5b58\u50a8\u4f4d\u7f6e\uff1a<span class=\"ez-toc-section-end\"><\/span><\/h2><h3><span class=\"ez-toc-section\" id=\"%E6%96%B9%E6%B3%951%EF%BC%9A_%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\"><\/span>\u65b9\u6cd51\uff1a \u4fee\u6539\u914d\u7f6e\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>mkdir -p \/etc\/docker<\/code><\/p><pre><span class=\"hljs-built_in\">cat<\/span> &gt; \/etc\/docker\/daemon.json &lt;&lt; <span class=\"hljs-string\">'EOF'<\/span><br \/>{<br \/>\"registry-mirrors\": [<br \/>\"https:\/\/docker.1ms.run\",<br \/>\"https:\/\/docker.1panel.live\",<br \/>\"https:\/\/docker.m.ixdev.cn\",<br \/>\"https:\/\/hub.rat.dev\",<br \/>\"https:\/\/docker.xuanyuan.me\",<br \/>\"https:\/\/dockerproxy.net\",<br \/>\"https:\/\/docker-registry.nmqu.com\",<br \/>\"https:\/\/hub.amingg.com\",<br \/>\"https:\/\/docker.amingg.com\",<br \/>\"https:\/\/docker.hlmirror.com\",<br \/>\"https:\/\/hub1.nat.tf\",<br \/>\"https:\/\/hub2.nat.tf\",<br \/>\"https:\/\/hub3.nat.tf\",<br \/>\"https:\/\/docker.m.daocloud.io\",<br \/>\"https:\/\/docker.kejilion.pro\",<br \/>\"https:\/\/docker.367231.xyz\",<br \/>\"https:\/\/hub.1panel.dev\",<br \/>\"https:\/\/dockerproxy.cool\",<br \/>\"https:\/\/docker.apiba.cn\",<br \/>\"https:\/\/proxy.vvvv.ee\"<br \/>],<br \/>\"data-root\": \"\/root\/data\"<br \/>}<\/pre><h3><span class=\"ez-toc-section\" id=\"%E6%96%B9%E6%B3%952%EF%BC%9A_%E4%BF%AE%E6%94%B9%E5%90%AF%E5%8A%A8%E9%80%89%E9%A1%B9\"><\/span>\u65b9\u6cd52\uff1a \u4fee\u6539\u542f\u52a8\u9009\u9879<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>systemctl cat docker<\/code> \u67e5\u770bsystemd\u6587\u4ef6\u4f4d\u7f6e<\/p><p>\u5728\u542f\u52a8\u9009\u9879\u540e\u52a0\u00a0 \u00a0 <code>--data-root=\/root\/data<\/code><\/p><p><code>ExecStart=\/usr\/bin\/dockerd --data-root=\/root\/data<\/code><\/p><h3><span class=\"ez-toc-section\" id=\"%E9%85%8D%E7%BD%AE%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91\"><\/span>\u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1<span class=\"ez-toc-section-end\"><\/span><\/h3><p>sed -i &#8216;s#^net.ipv4.ip_forward=0$#net.ipv4.ip_forward=1#g&#8217; \/etc\/sysctl.conf<br \/>sysctl -p &gt;&gt; temp.log<\/p><h3><span class=\"ez-toc-section\" id=\"%E5%90%AF%E5%8A%A8%E6%B5%8B%E8%AF%95\"><\/span>\u542f\u52a8\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h3><p>\u4fee\u6539\u540e\u8fdb\u884c\u5982\u4e0b\u64cd\u4f5c<\/p><p><code>systemctl\u00a0 daemon-reload<\/code><\/p><p><code>systemctl enable --now docker<\/code><\/p><p><a href=\"https:\/\/repo.linuxjk.cn\/docker%E9%95%9C%E5%83%8F\/nginx\/nginx_1.24-alpine.tar\">nginx1.24-alpine\u955c\u50cf<\/a><\/p><p>\u5feb\u901f\u542f\u52a8\u6d4b\u8bd5\uff1a<\/p><p><code>docker load -i &lt; nginx_1.24-alpine.tar<\/code><\/p><p><code>docker run -d -p 80:80 --name test_nginx nginx:1.24-alpine<\/code><\/p><p><code>curl -v http:\/\/localhost<\/code><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6848\u4e00\uff1a\u76f4\u63a5\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u6587\u4ef6 # 1. \u4e0b\u8f7d\u6700\u65b0\u7248 docker-composecurl -L &#8220;https:\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[20],"class_list":["post-2850","post","type-post","status-publish","format-standard","hentry","category-vxhs888p","tag-create_project"],"_links":{"self":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/2850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2850"}],"version-history":[{"count":31,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/2850\/revisions"}],"predecessor-version":[{"id":3117,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/2850\/revisions\/3117"}],"wp:attachment":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}