{"id":2850,"date":"2025-11-02T20:25:27","date_gmt":"2025-11-02T12:25:27","guid":{"rendered":"https:\/\/linuxjk.cn\/?p=2850"},"modified":"2026-07-16T14:23:26","modified_gmt":"2026-07-16T06:23:26","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 class=\"md-hr md-end-block\" tabindex=\"-1\"><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_88 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%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%EF%BC%8C%E6%8E%A8%E8%8D%90\" >\u65b9\u6848\u4e00\uff1a\u4f7f\u7528 Docker \u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5\uff0c\u63a8\u8350<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E4%B8%80%E3%80%81%E6%B7%BB%E5%8A%A0_Docker_%E5%AE%98%E6%96%B9%E4%BB%93%E5%BA%93\" >\u4e00\u3001\u6dfb\u52a0 Docker \u5b98\u65b9\u4ed3\u5e93<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E4%BA%8C%E3%80%81%E6%9B%BF%E6%8D%A2%E4%B8%BA%E5%9B%BD%E5%86%85%E6%BA%90%EF%BC%8C%E5%8F%AF%E9%80%89\" >\u4e8c\u3001\u66ff\u6362\u4e3a\u56fd\u5185\u6e90\uff0c\u53ef\u9009<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E4%BD%BF%E7%94%A8%E6%B8%85%E5%8D%8E%E6%BA%90\" >\u4f7f\u7528\u6e05\u534e\u6e90<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%88%96%E8%80%85%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8%E4%B8%AD%E7%A7%91%E5%A4%A7%E6%BA%90\" >\u6216\u8005\u76f4\u63a5\u4f7f\u7528\u4e2d\u79d1\u5927\u6e90<\/a><\/li><\/ul><\/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\/#%E4%B8%89%E3%80%81%E5%AE%89%E8%A3%85_Docker_%E5%92%8C_Docker_Compose_%E6%8F%92%E4%BB%B6\" >\u4e09\u3001\u5b89\u88c5 Docker \u548c Docker Compose \u63d2\u4ef6<\/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\/#%E5%9B%9B%E3%80%81%E5%90%AF%E5%8A%A8_Docker\" >\u56db\u3001\u542f\u52a8 Docker<\/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\/#%E4%BA%94%E3%80%81%E9%AA%8C%E8%AF%81_Docker_%E5%92%8C_Docker_Compose\" >\u4e94\u3001\u9a8c\u8bc1 Docker \u548c Docker Compose<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#Docker_Compose_%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F%E9%80%89%E6%8B%A9\" >Docker Compose \u5b89\u88c5\u65b9\u5f0f\u9009\u62e9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%8E%A8%E8%8D%90%E6%96%B9%E6%A1%88%EF%BC%9A%E4%BD%BF%E7%94%A8_docker-compose-plugin\" >\u63a8\u8350\u65b9\u6848\uff1a\u4f7f\u7528 docker-compose-plugin<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E5%A4%87%E7%94%A8%E6%96%B9%E6%A1%88%EF%BC%9A%E6%89%8B%E5%8A%A8%E5%AE%89%E8%A3%85_Docker_Compose_%E6%8F%92%E4%BB%B6\" >\u5907\u7528\u65b9\u6848\uff1a\u624b\u52a8\u5b89\u88c5 Docker Compose \u63d2\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E5%85%BC%E5%AE%B9%E6%96%B9%E6%A1%88%EF%BC%9A%E5%AE%89%E8%A3%85_legacy_docker-compose\" >\u517c\u5bb9\u65b9\u6848\uff1a\u5b89\u88c5 legacy docker-compose<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%96%B9%E6%A1%88%E4%BA%8C%EF%BC%9A%E7%9B%B4%E6%8E%A5%E4%B8%8B%E8%BD%BD_Docker_%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6%EF%BC%8C%E5%A4%87%E7%94%A8\" >\u65b9\u6848\u4e8c\uff1a\u76f4\u63a5\u4e0b\u8f7d Docker \u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u5907\u7528<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E4%B8%80%E3%80%81%E5%AE%89%E8%A3%85_Docker_%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6\" >\u4e00\u3001\u5b89\u88c5 Docker \u4e8c\u8fdb\u5236\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E4%BA%8C%E3%80%81%E4%B8%B4%E6%97%B6%E5%90%AF%E5%8A%A8_Docker_daemon\" >\u4e8c\u3001\u4e34\u65f6\u542f\u52a8 Docker daemon<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E4%B8%89%E3%80%81%E9%AA%8C%E8%AF%81_Docker\" >\u4e09\u3001\u9a8c\u8bc1 Docker<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E5%9B%9B%E3%80%81%E5%8D%B8%E8%BD%BD%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%AE%89%E8%A3%85%E7%9A%84_Docker\" >\u56db\u3001\u5378\u8f7d\u4e8c\u8fdb\u5236\u5b89\u88c5\u7684 Docker<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/linuxjk.cn\/?p=2850\/#%E6%80%BB%E7%BB%93\" >\u603b\u7ed3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" 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-20\" 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-21\" 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-22\" 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-23\" 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%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%EF%BC%8C%E6%8E%A8%E8%8D%90\"><\/span>\u65b9\u6848\u4e00\uff1a\u4f7f\u7528 Docker \u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5\uff0c\u63a8\u8350<span class=\"ez-toc-section-end\"><\/span><\/h2><p>\u672c\u6587\u4ee5 CentOS\/RHEL \u7cfb\u7edf\u4e3a\u4f8b\u3002<\/p><p>\u63a8\u8350\u987a\u5e8f\uff1a<\/p><ol start=\"1\"><li>\u4f18\u5148\u4f7f\u7528 Docker \u5b98\u65b9 yum\/dnf \u4ed3\u5e93\u5b89\u88c5 Docker<\/li><li>\u4f18\u5148\u4f7f\u7528 <code>docker-compose-plugin<\/code>\uff0c\u547d\u4ee4\u4e3a <code>docker compose<\/code><\/li><li>Docker CLI \u7248\u672c\u8fc7\u8001\u65f6\uff0c\u518d\u4f7f\u7528 legacy <code>docker-compose<\/code><\/li><li>\u4e8c\u8fdb\u5236\u5b89\u88c5\u65b9\u5f0f\u4ec5\u4f5c\u4e3a\u79bb\u7ebf\u6216\u7279\u6b8a\u573a\u666f\u5907\u7528\u65b9\u6848<\/li><\/ol><h3><span class=\"ez-toc-section\" id=\"%E4%B8%80%E3%80%81%E6%B7%BB%E5%8A%A0_Docker_%E5%AE%98%E6%96%B9%E4%BB%93%E5%BA%93\"><\/span>\u4e00\u3001\u6dfb\u52a0 Docker \u5b98\u65b9\u4ed3\u5e93<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>yum install -y yum-utils<\/code><\/p><p><code>yum-config-manager --add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo<\/code><\/p><hr \/><h3><span class=\"ez-toc-section\" id=\"%E4%BA%8C%E3%80%81%E6%9B%BF%E6%8D%A2%E4%B8%BA%E5%9B%BD%E5%86%85%E6%BA%90%EF%BC%8C%E5%8F%AF%E9%80%89\"><\/span>\u4e8c\u3001\u66ff\u6362\u4e3a\u56fd\u5185\u6e90\uff0c\u53ef\u9009<span class=\"ez-toc-section-end\"><\/span><\/h3><h4><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8%E6%B8%85%E5%8D%8E%E6%BA%90\"><\/span>\u4f7f\u7528\u6e05\u534e\u6e90<span class=\"ez-toc-section-end\"><\/span><\/h4><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><h4><span class=\"ez-toc-section\" id=\"%E6%88%96%E8%80%85%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8%E4%B8%AD%E7%A7%91%E5%A4%A7%E6%BA%90\"><\/span>\u6216\u8005\u76f4\u63a5\u4f7f\u7528\u4e2d\u79d1\u5927\u6e90<span class=\"ez-toc-section-end\"><\/span><\/h4><p><code>yum-config-manager --add-repo http:\/\/mirrors.ustc.edu.cn\/docker-ce\/linux\/centos\/docker-ce.repo<\/code><\/p><hr \/><h3><span class=\"ez-toc-section\" id=\"%E4%B8%89%E3%80%81%E5%AE%89%E8%A3%85_Docker_%E5%92%8C_Docker_Compose_%E6%8F%92%E4%BB%B6\"><\/span>\u4e09\u3001\u5b89\u88c5 Docker \u548c Docker Compose \u63d2\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/code><\/p><p>\u5982\u679c\u7cfb\u7edf\u4f7f\u7528\u7684\u662f <code>dnf<\/code>\uff1a<\/p><p><code>dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/code><\/p><hr \/><h3><span class=\"ez-toc-section\" id=\"%E5%9B%9B%E3%80%81%E5%90%AF%E5%8A%A8_Docker\"><\/span>\u56db\u3001\u542f\u52a8 Docker<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>systemctl enable --now docker<\/code><\/p><p><code>systemctl status docker<\/code><\/p><hr \/><h3><span class=\"ez-toc-section\" id=\"%E4%BA%94%E3%80%81%E9%AA%8C%E8%AF%81_Docker_%E5%92%8C_Docker_Compose\"><\/span>\u4e94\u3001\u9a8c\u8bc1 Docker \u548c Docker Compose<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>docker version<\/code><\/p><p><code>docker info<\/code><\/p><p><code>docker run hello-world<\/code><\/p><p><code>docker compose version<\/code><\/p><hr \/><h2><span class=\"ez-toc-section\" id=\"Docker_Compose_%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F%E9%80%89%E6%8B%A9\"><\/span>Docker Compose \u5b89\u88c5\u65b9\u5f0f\u9009\u62e9<span class=\"ez-toc-section-end\"><\/span><\/h2><p>\u5b89\u88c5 Docker Compose \u524d\uff0c\u5148\u67e5\u770b Docker CLI \u7248\u672c\uff1a<\/p><p><code>docker version<\/code><\/p><p>\u6216\u8005\u53ea\u67e5\u770b\u5ba2\u6237\u7aef\u7248\u672c\uff1a<\/p><p><code>docker version --format '{{.Client.Version}}'<\/code><\/p><p>\u9009\u62e9\u89c4\u5219\uff1a<\/p><ul><li>Docker CLI <code>&gt;= 18.09<\/code>\uff1a\u63a8\u8350\u4f7f\u7528 Docker CLI \u63d2\u4ef6\u65b9\u5f0f\uff0c\u547d\u4ee4\u662f <code>docker compose<\/code><\/li><li>Docker CLI <code>&lt; 18.09<\/code>\uff1a\u5927\u6982\u7387\u4e0d\u8bc6\u522b <code>cli-plugins<\/code>\uff0c\u53ea\u80fd\u5347\u7ea7 Docker CLI\uff0c\u6216\u4f7f\u7528 legacy <code>docker-compose<\/code><\/li><\/ul><hr \/><h2><span class=\"ez-toc-section\" id=\"%E6%8E%A8%E8%8D%90%E6%96%B9%E6%A1%88%EF%BC%9A%E4%BD%BF%E7%94%A8_docker-compose-plugin\"><\/span>\u63a8\u8350\u65b9\u6848\uff1a\u4f7f\u7528 docker-compose-plugin<span class=\"ez-toc-section-end\"><\/span><\/h2><p>\u5982\u679c\u524d\u9762\u5df2\u7ecf\u5b89\u88c5\u8fc7\uff1a<\/p><p><code>yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/code><\/p><p>\u901a\u5e38\u5df2\u7ecf\u5305\u542b Docker Compose \u63d2\u4ef6\u3002<\/p><p>\u9a8c\u8bc1\uff1a<\/p><p><code>docker compose version<\/code><\/p><p>\u4f7f\u7528\u65b9\u5f0f\uff1a<\/p><p><code>docker compose up -d<\/code><\/p><p><code>docker compose ps<\/code><\/p><p><code>docker compose logs -f<\/code><\/p><p><code>docker compose down<\/code><\/p><hr \/><h2><span class=\"ez-toc-section\" id=\"%E5%A4%87%E7%94%A8%E6%96%B9%E6%A1%88%EF%BC%9A%E6%89%8B%E5%8A%A8%E5%AE%89%E8%A3%85_Docker_Compose_%E6%8F%92%E4%BB%B6\"><\/span>\u5907\u7528\u65b9\u6848\uff1a\u624b\u52a8\u5b89\u88c5 Docker Compose \u63d2\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2><p>\u9002\u7528\u4e8e Docker \u5df2\u5b89\u88c5\u6210\u529f\uff0c\u4f46\u7cfb\u7edf\u4ed3\u5e93\u4e2d\u6ca1\u6709 <code>docker-compose-plugin<\/code> \u7684\u573a\u666f\u3002<\/p><p><code>mkdir -p \/usr\/local\/lib\/docker\/cli-plugins<\/code><\/p><p><code>curl -L \"https:\/\/github.com\/docker\/compose\/releases\/latest\/download\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/lib\/docker\/cli-plugins\/docker-compose<\/code><\/p><p><code>chmod +x \/usr\/local\/lib\/docker\/cli-plugins\/docker-compose<\/code><\/p><p><code>docker compose version<\/code><\/p><p>\u5982\u679c\u9700\u8981\u56fa\u5b9a Docker Compose \u7248\u672c\uff1a<\/p><p><code>curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/v2.24.1\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/lib\/docker\/cli-plugins\/docker-compose<\/code><\/p><p><code>chmod +x \/usr\/local\/lib\/docker\/cli-plugins\/docker-compose<\/code><\/p><p><code>docker compose version<\/code><\/p><hr \/><h2><span class=\"ez-toc-section\" id=\"%E5%85%BC%E5%AE%B9%E6%96%B9%E6%A1%88%EF%BC%9A%E5%AE%89%E8%A3%85_legacy_docker-compose\"><\/span>\u517c\u5bb9\u65b9\u6848\uff1a\u5b89\u88c5 legacy docker-compose<span class=\"ez-toc-section-end\"><\/span><\/h2><p>\u9002\u7528\u4e8e Docker CLI \u7248\u672c\u8fc7\u8001\uff0c\u6216\u8005\u9700\u8981\u517c\u5bb9\u8001\u811a\u672c\u7684\u573a\u666f\u3002<\/p><p>\u5b89\u88c5\u540e\u4f7f\u7528\uff1a<\/p><p><code>docker-compose<\/code><\/p><p>\u5b89\u88c5\u547d\u4ee4\uff1a<\/p><p><code>curl -L \"https:\/\/github.com\/docker\/compose\/releases\/latest\/download\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose<\/code><\/p><p><code>chmod +x \/usr\/local\/bin\/docker-compose<\/code><\/p><p><code>ln -sf \/usr\/local\/bin\/docker-compose \/usr\/bin\/docker-compose<\/code><\/p><p><code>docker-compose version<\/code><\/p><hr \/><h2><span class=\"ez-toc-section\" id=\"%E6%96%B9%E6%A1%88%E4%BA%8C%EF%BC%9A%E7%9B%B4%E6%8E%A5%E4%B8%8B%E8%BD%BD_Docker_%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6%EF%BC%8C%E5%A4%87%E7%94%A8\"><\/span>\u65b9\u6848\u4e8c\uff1a\u76f4\u63a5\u4e0b\u8f7d Docker \u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u5907\u7528<span class=\"ez-toc-section-end\"><\/span><\/h2><p><span style=\"font-size: 16px;\">\u4e0d\u63a8\u8350\u4f5c\u4e3a\u5e38\u89c4\u5b89\u88c5\u65b9\u5f0f\u3002<\/span><\/p><p>\u4e8c\u8fdb\u5236\u5b89\u88c5\u9002\u5408\u79bb\u7ebf\u73af\u5883\u3001\u4e34\u65f6\u6d4b\u8bd5\u6216\u7279\u6b8a\u7cfb\u7edf\u73af\u5883\u3002<br \/>\u5982\u679c\u670d\u52a1\u5668\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528 yum\/dnf\uff0c\u5efa\u8bae\u4f18\u5148\u4f7f\u7528\u65b9\u6848\u4e00\u3002<\/p><h3><span class=\"ez-toc-section\" id=\"%E4%B8%80%E3%80%81%E5%AE%89%E8%A3%85_Docker_%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6\"><\/span>\u4e00\u3001\u5b89\u88c5 Docker \u4e8c\u8fdb\u5236\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>wget https:\/\/download.docker.com\/linux\/static\/stable\/x86_64\/docker-29.0.4.tgz<\/code><\/p><p><code>tar xzvf docker-29.0.4.tgz<\/code><\/p><p><code>cp docker\/* \/usr\/bin\/<\/code><\/p><p><code>docker --version<\/code><\/p><p><code>dockerd --version<\/code><\/p><hr \/><h3><span class=\"ez-toc-section\" id=\"%E4%BA%8C%E3%80%81%E4%B8%B4%E6%97%B6%E5%90%AF%E5%8A%A8_Docker_daemon\"><\/span>\u4e8c\u3001\u4e34\u65f6\u542f\u52a8 Docker daemon<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>dockerd &amp;<\/code><\/p><blockquote><p>\u6ce8\u610f\uff1a<br \/>\u4f7f\u7528\u4e8c\u8fdb\u5236\u65b9\u5f0f\u5b89\u88c5\u65f6\uff0c<code>dockerd &amp;<\/code> \u53ea\u9002\u5408\u4e34\u65f6\u542f\u52a8\u3002<br \/>\u5982\u679c\u9700\u8981\u957f\u671f\u4f7f\u7528\uff0c\u5efa\u8bae\u4ecd\u7136\u6539\u7528 yum\/dnf \u5b89\u88c5\uff0c\u5e76\u901a\u8fc7 <code>systemd<\/code> \u7ba1\u7406 Docker \u670d\u52a1\u3002<\/p><\/blockquote><hr \/><h3><span class=\"ez-toc-section\" id=\"%E4%B8%89%E3%80%81%E9%AA%8C%E8%AF%81_Docker\"><\/span>\u4e09\u3001\u9a8c\u8bc1 Docker<span class=\"ez-toc-section-end\"><\/span><\/h3><p><code>docker info<\/code><\/p><p><code>docker run hello-world<\/code><\/p><hr \/><h3><span class=\"ez-toc-section\" id=\"%E5%9B%9B%E3%80%81%E5%8D%B8%E8%BD%BD%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%AE%89%E8%A3%85%E7%9A%84_Docker\"><\/span>\u56db\u3001\u5378\u8f7d\u4e8c\u8fdb\u5236\u5b89\u88c5\u7684 Docker<span class=\"ez-toc-section-end\"><\/span><\/h3><blockquote><p>\u6ce8\u610f\uff1a<br \/>\u4ee5\u4e0b\u547d\u4ee4\u53ea\u9002\u7528\u4e8e\u901a\u8fc7 <code>cp docker\/* \/usr\/bin\/<\/code> \u8fd9\u79cd\u4e8c\u8fdb\u5236\u65b9\u5f0f\u5b89\u88c5\u7684 Docker\u3002<br \/>\u5982\u679c Docker \u662f\u901a\u8fc7 yum\/dnf \u5b89\u88c5\u7684\uff0c\u4e0d\u8981\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u5378\u8f7d\u3002<\/p><\/blockquote><p><code>pkill dockerd<\/code><\/p><p><code>pkill containerd<\/code><\/p><p><code>rm -f \/usr\/bin\/docker<\/code><\/p><p><code>rm -f \/usr\/bin\/dockerd<\/code><\/p><p><code>rm -f \/usr\/bin\/docker-init<\/code><\/p><p><code>rm -f \/usr\/bin\/docker-proxy<\/code><\/p><p><code>rm -f \/usr\/bin\/containerd<\/code><\/p><p><code>rm -f \/usr\/bin\/containerd-shim<\/code><\/p><p><code>rm -f \/usr\/bin\/containerd-shim-runc-v2<\/code><\/p><p><code>rm -f \/usr\/bin\/ctr<\/code><\/p><p><code>rm -f \/usr\/bin\/runc<\/code><\/p><p><code>rm -f \/usr\/local\/lib\/docker\/cli-plugins\/docker-compose<\/code><\/p><p><code>rm -f \/usr\/local\/bin\/docker-compose<\/code><\/p><p><code>rm -f \/usr\/bin\/docker-compose<\/code><\/p><p>\u5982\u679c\u9700\u8981\u5f7b\u5e95\u6e05\u7406 Docker \u6570\u636e\uff0c\u53ef\u4ee5\u6267\u884c\uff1a<\/p><p><code>rm -rf \/var\/lib\/docker<\/code><\/p><p><code>rm -rf \/var\/lib\/containerd<\/code><\/p><p><code>rm -rf \/etc\/docker<\/code><\/p><blockquote><p>\u6ce8\u610f\uff1a<br \/>\u5f7b\u5e95\u6e05\u7406\u4f1a\u5220\u9664\u6240\u6709\u955c\u50cf\u3001\u5bb9\u5668\u3001\u5377\u548c containerd \u6570\u636e\u3002<\/p><\/blockquote><hr \/><h2><span class=\"ez-toc-section\" id=\"%E6%80%BB%E7%BB%93\"><\/span>\u603b\u7ed3<span class=\"ez-toc-section-end\"><\/span><\/h2><p>\u63a8\u8350\u5b89\u88c5\u65b9\u5f0f\uff1a<\/p><p><code>yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/code><\/p><p><code>systemctl enable --now docker<\/code><\/p><p><code>docker compose version<\/code><\/p><p>\u63a8\u8350\u4f7f\u7528\u65b0\u7248 Compose \u547d\u4ee4\uff1a<\/p><p><code>docker compose<\/code><\/p><p>\u65e7\u7248\u517c\u5bb9\u547d\u4ee4\uff1a<\/p><p><code>docker-compose<\/code><\/p><p>\u53ea\u5efa\u8bae\u5728\u4ee5\u4e0b\u573a\u666f\u4f7f\u7528\uff1a<\/p><ul><li>Docker CLI \u7248\u672c\u8fc7\u8001\uff0c\u4e0d\u652f\u6301 <code>cli-plugins<\/code><\/li><li>\u8001\u9879\u76ee\u811a\u672c\u4e2d\u5df2\u7ecf\u5199\u6b7b\u4e86 <code>docker-compose<\/code><\/li><li>\u6682\u65f6\u65e0\u6cd5\u5347\u7ea7 Docker CLI<\/li><\/ul><\/div>\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\u4f7f\u7528 Docker \u5b98\u65b9\u4ed3\u5e93\u5b89\u88c5\uff0c\u63a8\u8350 \u672c\u6587\u4ee5 CentOS\/RHEL \u7cfb\u7edf\u4e3a\u4f8b\u3002 \u63a8\u8350\u987a\u5e8f\uff1a \u4f18\u5148\u4f7f [&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":37,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/2850\/revisions"}],"predecessor-version":[{"id":3237,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/2850\/revisions\/3237"}],"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}]}}