{"id":33183,"date":"2025-04-27T01:10:25","date_gmt":"2025-04-26T17:10:25","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/33183.html"},"modified":"2025-04-27T01:10:25","modified_gmt":"2025-04-26T17:10:25","slug":"4-%e5%8f%b0-2c2g-%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%80%86%e8%a2%ad%ef%bc%81%e6%89%8b%e6%8a%8a%e6%89%8b%e6%95%99%e4%bd%a0%e7%94%a8-docker-swarmportainer-%e6%89%93%e9%80%a0%e8%b6%85%e4%be%bf%e6%8d%b7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/33183.html","title":{"rendered":"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4"},"content":{"rendered":"<h2>4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad&#xff01;\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm&#043;Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4<\/h2>\n<p>\u5728\u8d44\u6e90\u6709\u9650\u7684\u60c5\u51b5\u4e0b&#xff0c;\u5982\u4f55\u6700\u5927\u5316\u670d\u52a1\u5668\u6027\u80fd&#xff1f;\u672c\u6587\u5c06\u57fa\u4e8e 4 \u53f0 2C2G \u670d\u52a1\u5668&#xff0c;\u5e26\u4f60\u901a\u8fc7 Docker Swarm \u548c Portainer \u6784\u5efa\u9ad8\u6548\u96c6\u7fa4&#xff0c;\u8f7b\u677e\u5b9e\u73b0\u8d44\u6e90\u6574\u5408\u4e0e\u53ef\u89c6\u5316\u7ba1\u7406\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250426171024-680d138075869.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u4e00\u3001\u96c6\u7fa4\u89c4\u5212\u4e0e\u67b6\u6784\u8bbe\u8ba1<\/h3>\n<h4>1. \u786c\u4ef6\u914d\u7f6e<\/h4>\n<p>4 \u53f0 2C2G \u670d\u52a1\u5668&#xff08;\u793a\u4f8b IP&#xff1a;192.168.1.100~192.168.1.103&#xff09;&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u7edf\u4e00\u662f\u4f7f\u7528 Ubuntu 20.04 LTS\u3002<\/p>\n<h4>2. \u89d2\u8272\u5206\u914d<\/h4>\n<table>\n<tr>\u8282\u70b9 IP\u89d2\u8272\u804c\u8d23\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>192.168.1.100<\/td>\n<td>Swarm Manager<\/td>\n<td>\u96c6\u7fa4\u7ba1\u7406\u8282\u70b9&#xff08;\u4e3b\u7ba1\u7406\u8282\u70b9&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>192.168.1.101<\/td>\n<td>Swarm Worker<\/td>\n<td>\u5de5\u4f5c\u8282\u70b9<\/td>\n<\/tr>\n<tr>\n<td>192.168.1.102<\/td>\n<td>Swarm Worker<\/td>\n<td>\u5de5\u4f5c\u8282\u70b9<\/td>\n<\/tr>\n<tr>\n<td>192.168.1.103<\/td>\n<td>Swarm Worker<\/td>\n<td>\u5de5\u4f5c\u8282\u70b9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3. \u67b6\u6784\u56fe<\/h4>\n<p>  #mermaid-svg-EOB4zzZHZYRycCTA {font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-EOB4zzZHZYRycCTA .error-icon{fill:#552222;}#mermaid-svg-EOB4zzZHZYRycCTA .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-EOB4zzZHZYRycCTA .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-EOB4zzZHZYRycCTA .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-EOB4zzZHZYRycCTA .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-EOB4zzZHZYRycCTA .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-EOB4zzZHZYRycCTA .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-EOB4zzZHZYRycCTA .marker{fill:#333333;stroke:#333333;}#mermaid-svg-EOB4zzZHZYRycCTA .marker.cross{stroke:#333333;}#mermaid-svg-EOB4zzZHZYRycCTA svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-EOB4zzZHZYRycCTA .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-EOB4zzZHZYRycCTA .cluster-label text{fill:#333;}#mermaid-svg-EOB4zzZHZYRycCTA .cluster-label span{color:#333;}#mermaid-svg-EOB4zzZHZYRycCTA .label text,#mermaid-svg-EOB4zzZHZYRycCTA span{fill:#333;color:#333;}#mermaid-svg-EOB4zzZHZYRycCTA .node rect,#mermaid-svg-EOB4zzZHZYRycCTA .node circle,#mermaid-svg-EOB4zzZHZYRycCTA .node ellipse,#mermaid-svg-EOB4zzZHZYRycCTA .node polygon,#mermaid-svg-EOB4zzZHZYRycCTA .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-EOB4zzZHZYRycCTA .node .label{text-align:center;}#mermaid-svg-EOB4zzZHZYRycCTA .node.clickable{cursor:pointer;}#mermaid-svg-EOB4zzZHZYRycCTA .arrowheadPath{fill:#333333;}#mermaid-svg-EOB4zzZHZYRycCTA .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-EOB4zzZHZYRycCTA .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-EOB4zzZHZYRycCTA .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-EOB4zzZHZYRycCTA .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-EOB4zzZHZYRycCTA .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-EOB4zzZHZYRycCTA .cluster text{fill:#333;}#mermaid-svg-EOB4zzZHZYRycCTA .cluster span{color:#333;}#mermaid-svg-EOB4zzZHZYRycCTA div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-EOB4zzZHZYRycCTA :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;} <\/p>\n<p>           \u5de5\u4f5c\u8282\u70b9 <\/p>\n<p>           \u7ba1\u7406\u8282\u70b9 <\/p>\n<p>         <span id=\"L-L-A-B\" class=\"edgeLabel L-LS-A&#039; L-LE-B\">Swarm\u7ba1\u7406API<\/span> <\/p>\n<p>         <span id=\"L-L-A-C\" class=\"edgeLabel L-LS-A&#039; L-LE-C\">Swarm\u7ba1\u7406API<\/span> <\/p>\n<p>         <span id=\"L-L-A-D\" class=\"edgeLabel L-LS-A&#039; L-LE-D\">Swarm\u7ba1\u7406API<\/span> <\/p>\n<p>         <span id=\"L-L-A-E\" class=\"edgeLabel L-LS-A&#039; L-LE-E\">Portainer 9000\u7aef\u53e3<\/span> <\/p>\n<p>         <span id=\"L-L-B-F\" class=\"edgeLabel L-LS-B&#039; L-LE-F\">\u5bb9\u5668\u670d\u52a1<\/span> <\/p>\n<p>         <span id=\"L-L-C-F\" class=\"edgeLabel L-LS-C&#039; L-LE-F\">\u5bb9\u5668\u670d\u52a1<\/span> <\/p>\n<p>         <span id=\"L-L-D-F\" class=\"edgeLabel L-LS-D&#039; L-LE-F\">\u5bb9\u5668\u670d\u52a1<\/span> <\/p>\n<p>           192.168.1.101 <\/p>\n<p>           192.168.1.102 <\/p>\n<p>           192.168.1.103 <\/p>\n<p>           192.168.1.100 <\/p>\n<p>           \u5ba2\u6237\u7aef\u6d4f\u89c8\u5668 <\/p>\n<p>           \u5e94\u7528\u5bb9\u5668 <\/p>\n<h3>\u4e8c\u3001\u73af\u5883\u51c6\u5907&#xff08;\u6240\u6709\u8282\u70b9&#xff09;<\/h3>\n<h4>1. \u5b89\u88c5 Docker CE<\/h4>\n<p>\\\\# \u66f4\u65b0\u5305\u7d22\u5f15<\/p>\n<p>sudo apt update<\/p>\n<p>\\\\# \u5b89\u88c5\u4f9d\u8d56\u5de5\u5177<\/p>\n<p>sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common<\/p>\n<p>\\\\# \u6dfb\u52a0Docker\u5b98\u65b9GPG\u5bc6\u94a5<\/p>\n<p>curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo apt-key add &#8211;<\/p>\n<p>\\\\# \u6dfb\u52a0Docker\u8f6f\u4ef6\u6e90<\/p>\n<p>sudo add-apt-repository &#034;deb \\\\[arch&#061;amd64] https:\/\/download.docker.com\/linux\/ubuntu \\\\$(lsb\\\\_release -cs) stable&#034;<\/p>\n<p>\\\\# \u5b89\u88c5Docker CE<\/p>\n<p>sudo apt install -y docker-ce docker-ce-cli containerd.io<\/p>\n<p>\\\\# \u542f\u52a8Docker\u670d\u52a1\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/p>\n<p>sudo systemctl enable &#8211;now docker<\/p>\n<p>\\\\# \u5141\u8bb8\u5f53\u524d\u7528\u6237\u7ba1\u7406Docker&#xff08;\u975e\u5fc5\u987b&#xff0c;\u5efa\u8bae\u4f7f\u7528sudo&#xff09;<\/p>\n<p>sudo usermod -aG docker \\\\$USER<\/p>\n<h4>2. \u68c0\u67e5 Docker \u7248\u672c&#xff08;\u9700 &gt;&#061;1.12&#xff09;<\/h4>\n<p>docker &#8211;version<\/p>\n<p>\\\\# \u9884\u671f\u8f93\u51fa\u7c7b\u4f3c&#xff1a;Docker version 24.0.6, build ed223bc<\/p>\n<h4>3. \u5f00\u653e\u96c6\u7fa4\u901a\u4fe1\u7aef\u53e3&#xff08;\u6240\u6709\u8282\u70b9&#xff09;<\/h4>\n<p>sudo ufw allow 2377\/tcp   # Swarm\u7ba1\u7406\u7aef\u53e3<\/p>\n<p>sudo ufw allow 7946\/tcp   # \u5bb9\u5668\u7f51\u7edc\u901a\u4fe1&#xff08;TCP&#xff09;<\/p>\n<p>sudo ufw allow 7946\/udp   # \u5bb9\u5668\u7f51\u7edc\u901a\u4fe1&#xff08;UDP&#xff09;<\/p>\n<p>sudo ufw allow 4789\/udp   # \u5bb9\u5668overlay\u7f51\u7edc<\/p>\n<p>sudo ufw allow 9000\/tcp   # Portainer\u7ba1\u7406\u7aef\u53e3&#xff08;\u4ec5\u7ba1\u7406\u8282\u70b9&#xff09;<\/p>\n<p>sudo ufw enable<\/p>\n<h3>\u4e09\u3001\u521d\u59cb\u5316 Swarm \u96c6\u7fa4&#xff08;\u7ba1\u7406\u8282\u70b9 192.168.1.100&#xff09;<\/h3>\n<h4>1. \u521d\u59cb\u5316\u7ba1\u7406\u8282\u70b9<\/h4>\n<p>docker swarm init &#8211;advertise-addr 192.168.1.100<\/p>\n<p>\u6267\u884c\u540e\u4f1a\u8f93\u51fa\u5de5\u4f5c\u8282\u70b9\u52a0\u5165\u547d\u4ee4&#xff0c;\u7c7b\u4f3c&#xff1a;<\/p>\n<p>Swarm initialized: current node (abcdef123456) is now a manager.<\/p>\n<p>To add a worker to this swarm, run the following command:<\/p>\n<p>docker swarm join &#8211;token SWMTKN-1-4567890abcdef1234567890 192.168.1.100:2377<\/p>\n<h4>2. \u67e5\u770b\u96c6\u7fa4\u8282\u70b9\u72b6\u6001<\/h4>\n<p>docker node ls<\/p>\n<p>\\\\# \u9884\u671f\u8f93\u51fa&#xff1a;\u53ea\u6709\u5f53\u524d\u7ba1\u7406\u8282\u70b9&#xff0c;\u72b6\u6001\u4e3aReady&#xff0c;\u89d2\u8272\u4e3aManager<\/p>\n<h3>\u56db\u3001\u6dfb\u52a0\u5de5\u4f5c\u8282\u70b9&#xff08;192.168.1.101~103&#xff09;<\/h3>\n<p>\u5728\u6bcf\u53f0\u5de5\u4f5c\u8282\u70b9\u6267\u884c\u521d\u59cb\u5316\u65f6\u8f93\u51fa\u7684\u52a0\u5165\u547d\u4ee4&#xff1a;<\/p>\n<p>docker swarm join &#8211;token SWMTKN-1-4567890abcdef1234567890 192.168.1.100:2377<\/p>\n<h4>\u9a8c\u8bc1\u8282\u70b9\u52a0\u5165<\/h4>\n<p>\u5728\u7ba1\u7406\u8282\u70b9\u518d\u6b21\u6267\u884c&#xff1a;<\/p>\n<p>docker node ls<\/p>\n<p>\\\\# \u9884\u671f\u8f93\u51fa4\u4e2a\u8282\u70b9&#xff0c;1\u4e2aManager&#xff0c;3\u4e2aWorker&#xff0c;\u72b6\u6001\u5747\u4e3aReady<\/p>\n<h3>\u4e94\u3001\u90e8\u7f72 Portainer \u53ef\u89c6\u5316\u7ba1\u7406\u5de5\u5177&#xff08;\u7ba1\u7406\u8282\u70b9&#xff09;<\/h3>\n<h4>1. \u521b\u5efa\u6570\u636e\u5377&#xff08;\u6301\u4e45\u5316\u5b58\u50a8\u914d\u7f6e&#xff09;<\/h4>\n<p>docker volume create portainer\\\\_data<\/p>\n<h4>2. \u8fd0\u884c Portainer \u670d\u52a1<\/h4>\n<p>docker service create \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;name portainer \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;publish 9000:9000 \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;constraint &#039;node.role &#061;&#061; manager&#039; \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;mount type&#061;bind,src&#061;\/\/var\/run\/docker.sock,dst&#061;\/var\/run\/docker.sock \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;mount type&#061;volume,src&#061;portainer\\\\_data,dst&#061;\/data \\\\\\\\<\/p>\n<p>&#x20; portainer\/portainer-ce:latest -H unix:\/\/\/var\/run\/docker.sock<\/p>\n<p>\u53c2\u6570\u8bf4\u660e&#xff1a;<\/p>\n<p>&#8211;constraint&#xff1a;\u786e\u4fdd Portainer \u4ec5\u5728\u7ba1\u7406\u8282\u70b9\u8fd0\u884c<\/p>\n<p>&#8211;mount&#xff1a;\u6302\u8f7d Docker \u5957\u63a5\u5b57\u5b9e\u73b0\u96c6\u7fa4\u7ba1\u7406&#xff0c;\u6570\u636e\u5377\u5b58\u50a8\u914d\u7f6e<\/p>\n<h4>3. \u8bbf\u95ee Portainer \u754c\u9762<\/h4>\n<p>\u5728\u6d4f\u89c8\u5668\u8f93\u5165&#xff1a;http:\/\/192.168.1.100:9000<\/p>\n<p>\u9996\u6b21\u8bbf\u95ee\u8bbe\u7f6e\u7ba1\u7406\u5458\u5bc6\u7801&#xff08;\u5efa\u8bae\u5f3a\u5bc6\u7801&#xff09;<\/p>\n<p>\u9009\u62e9 \u201cConnect to a Docker environment\u201d<\/p>\n<p>\u9009\u62e9 \u201cSwarm mode\u201d \u5e76\u70b9\u51fb \u201cConnect\u201d<\/p>\n<h3>\u516d\u3001\u96c6\u7fa4\u9a8c\u8bc1\u4e0e\u57fa\u672c\u64cd\u4f5c<\/h3>\n<h4>1. \u67e5\u770b\u8282\u70b9\u72b6\u6001&#xff08;Portainer \u754c\u9762&#xff09;<\/h4>\n<p>\u8fdb\u5165 \u201cNodes\u201d \u9875\u9762&#xff0c;\u5e94\u663e\u793a 4 \u4e2a\u8282\u70b9&#xff0c;\u72b6\u6001\u5747\u4e3a Active<\/p>\n<p>Manager \u8282\u70b9\u663e\u793a \u201cLeader\u201d \u6807\u8bc6&#xff0c;Worker \u8282\u70b9\u663e\u793a\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5<\/p>\n<h4>2. \u90e8\u7f72\u6d4b\u8bd5\u670d\u52a1&#xff08;Nginx \u793a\u4f8b&#xff09;<\/h4>\n<h5>\u547d\u4ee4\u884c\u90e8\u7f72&#xff08;\u7ba1\u7406\u8282\u70b9&#xff09;<\/h5>\n<p>docker service create \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;name web-service \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;replicas 3 \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;port 80:80 \\\\\\\\<\/p>\n<p>&#x20; nginx:alpine<\/p>\n<h5>Portainer \u754c\u9762\u90e8\u7f72<\/h5>\n<p>\u8fdb\u5165 \u201cStacks\u201d \u9875\u9762&#xff0c;\u70b9\u51fb \u201cAdd stack\u201d<\/p>\n<p>\u4f7f\u7528 Docker Compose \u683c\u5f0f\u90e8\u7f72&#xff08;\u793a\u4f8b\u5982\u4e0b&#xff09;&#xff1a;<\/p>\n<p>version: &#039;3&#039;<\/p>\n<p>services:<\/p>\n<p>&#x20; web:<\/p>\n<p>&#x20;   image: nginx:alpine<\/p>\n<p>&#x20;   ports:<\/p>\n<p>&#x20;     \\\\- &#034;80:80&#034;<\/p>\n<p>&#x20;   deploy:<\/p>\n<p>&#x20;     replicas: 3<\/p>\n<h4>3. \u9a8c\u8bc1\u8d1f\u8f7d\u5747\u8861<\/h4>\n<p>\u8bbf\u95ee\u4efb\u610f\u8282\u70b9 IP \u7684 80 \u7aef\u53e3&#xff0c;\u4f1a\u8f6e\u8be2\u5230\u4e0d\u540c Nginx \u5bb9\u5668\u5b9e\u4f8b<\/p>\n<p>curl 192.168.1.100<\/p>\n<p>curl 192.168.1.101<\/p>\n<p>\\\\# \u8f93\u51fa\u5e94\u663e\u793a\u4e0d\u540c\u7684\u5bb9\u5668ID&#xff08;\u901a\u8fc7\u67e5\u770b\u5bb9\u5668\u65e5\u5fd7\u786e\u8ba4&#xff09;<\/p>\n<h3>\u4e03\u3001\u8d44\u6e90\u4f18\u5316\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h3>\n<h4>1. \u9650\u5236\u5bb9\u5668\u8d44\u6e90&#xff08;\u9632\u6b62\u5355\u4e2a\u5bb9\u5668\u8017\u5c3d\u8282\u70b9\u8d44\u6e90&#xff09;<\/h4>\n<p>docker service create \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;name restricted-service \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;replicas 2 \\\\\\\\<\/p>\n<p>&#x20; \\\\&#8211;limit-cpu 1.0 \\\\        # \u6700\u591a\u4f7f\u75281\u4e2aCPU\u6838\u5fc3<\/p>\n<p>&#x20; \\\\&#8211;limit-memory 1024m \\\\   # \u6700\u591a\u4f7f\u75281GB\u5185\u5b58<\/p>\n<p>&#x20; \\\\&#8211;reserve-cpu 0.5 \\\\      # \u81f3\u5c11\u4fdd\u75590.5\u4e2aCPU<\/p>\n<p>&#x20; \\\\&#8211;reserve-memory 512m \\\\  # \u81f3\u5c11\u4fdd\u7559512MB\u5185\u5b58<\/p>\n<p>&#x20; nginx:alpine<\/p>\n<h4>2. \u8282\u70b9\u6807\u7b7e\u5206\u7ec4&#xff08;\u793a\u4f8b&#xff1a;\u533a\u5206\u6570\u636e\u5e93\u8282\u70b9&#xff09;<\/h4>\n<h5>\u4e3a\u7279\u5b9a\u8282\u70b9\u6dfb\u52a0\u6807\u7b7e<\/h5>\n<p>docker node update &#8211;label-add role&#061;database 192.168.1.101<\/p>\n<h5>\u90e8\u7f72\u670d\u52a1\u65f6\u6307\u5b9a\u6807\u7b7e\u7ea6\u675f<\/h5>\n<p>deploy:<\/p>\n<p>&#x20; placement:<\/p>\n<p>&#x20;   constraints:<\/p>\n<p>&#x20;     \\\\- node.labels.role &#061;&#061; database<\/p>\n<h4>3. \u76d1\u63a7\u96c6\u7fa4\u8d44\u6e90<\/h4>\n<p>\u5728 Portainer \u754c\u9762\u7684 \u201cMonitoring\u201d \u9875\u9762\u53ef\u5b9e\u65f6\u67e5\u770b&#xff1a;<\/p>\n<p>\u8282\u70b9 CPU \/ \u5185\u5b58 \/ \u78c1\u76d8\u4f7f\u7528\u60c5\u51b5<\/p>\n<p>\u670d\u52a1\u526f\u672c\u8fd0\u884c\u72b6\u6001<\/p>\n<p>\u5bb9\u5668\u65e5\u5fd7\u5b9e\u65f6\u76d1\u63a7<\/p>\n<h3>\u516b\u3001\u5e38\u89c1\u95ee\u9898\u5904\u7406<\/h3>\n<h4>1. \u8282\u70b9\u52a0\u5165\u5931\u8d25<\/h4>\n<p>\u68c0\u67e5\u9632\u706b\u5899\u662f\u5426\u5f00\u653e 2377\/7946\/4789 \u7aef\u53e3<\/p>\n<p>\u786e\u8ba4\u7ba1\u7406\u8282\u70b9 IP \u53ef\u88ab\u5de5\u4f5c\u8282\u70b9\u8bbf\u95ee&#xff08;ping \u6d4b\u8bd5&#xff09;<\/p>\n<p>\u91cd\u65b0\u751f\u6210\u52a0\u5165\u4ee4\u724c&#xff1a;docker swarm join-token worker<\/p>\n<h4>2. Portainer \u65e0\u6cd5\u8fde\u63a5\u96c6\u7fa4<\/h4>\n<p>\u68c0\u67e5\/var\/run\/docker.sock\u6743\u9650\u662f\u5426\u6b63\u786e<\/p>\n<p>\u91cd\u542f Portainer \u670d\u52a1&#xff1a;docker service rm portainer &amp;&amp; \u91cd\u65b0\u6267\u884c\u90e8\u7f72\u547d\u4ee4<\/p>\n<h4>3. \u670d\u52a1\u8c03\u5ea6\u4e0d\u5747\u8861<\/h4>\n<p>\u68c0\u67e5\u8282\u70b9\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5&#xff08;Portainer \u76d1\u63a7\u9875\u9762&#xff09;<\/p>\n<p>\u6dfb\u52a0\u8d44\u6e90\u7ea6\u675f\u6216\u8282\u70b9\u6807\u7b7e\u91cd\u65b0\u8c03\u5ea6\u4efb\u52a1<\/p>\n<h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<p>\u901a\u8fc7 4 \u53f0 2C2G \u670d\u52a1\u5668\u642d\u5efa\u7684 Docker Swarm \u96c6\u7fa4&#xff0c;\u914d\u5408 Portainer \u53ef\u89c6\u5316\u7ba1\u7406&#xff0c;\u5b9e\u73b0\u4e86&#xff1a;<\/p>\n<p>\u8ba1\u7b97\u8d44\u6e90\u7684\u96c6\u4e2d\u7ba1\u7406\u4e0e\u5f39\u6027\u5206\u914d<\/p>\n<p>\u5bb9\u5668\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u4e0e\u8d1f\u8f7d\u5747\u8861<\/p>\n<p>\u53ef\u89c6\u5316\u7684\u96c6\u7fa4\u76d1\u63a7\u4e0e\u4fbf\u6377\u64cd\u4f5c<\/p>\n<p>\u6b64\u65b9\u6848\u9002\u7528\u4e8e\u4e2d\u5c0f\u89c4\u6a21\u5fae\u670d\u52a1\u67b6\u6784\u3001\u5206\u5e03\u5f0f\u5e94\u7528\u6d4b\u8bd5\u73af\u5883\u6216\u8f7b\u91cf\u7ea7\u751f\u4ea7\u96c6\u7fa4\u3002\u540e\u7eed\u53ef\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u6269\u5c55\u8282\u70b9\u6570\u91cf&#xff0c;\u901a\u8fc7 Swarm \u7684\u52a8\u6001\u8c03\u5ea6\u80fd\u529b\u7075\u6d3b\u5206\u914d\u8d44\u6e90\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb916\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u901a\u8fc7 4 \u53f0 2C2G \u670d\u52a1\u5668\u642d\u5efa\u7684 Docker Swarm \u96c6\u7fa4\uff0c\u914d\u5408 Portainer \u53ef\u89c6\u5316\u7ba1\u7406\uff0c\u5b9e\u73b0\u4e86\uff1a\u8ba1\u7b97\u8d44\u6e90\u7684\u96c6\u4e2d\u7ba1\u7406\u4e0e\u5f39\u6027\u5206\u914d\u5bb9\u5668\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u4e0e\u8d1f\u8f7d\u5747\u8861\u53ef\u89c6\u5316\u7684\u96c6\u7fa4\u76d1\u63a7\u4e0e\u4fbf\u6377\u64cd\u4f5c\u6b64\u65b9\u6848\u9002\u7528\u4e8e\u4e2d\u5c0f\u89c4\u6a21\u5fae\u670d\u52a1\u67b6\u6784\u3001\u5206\u5e03\u5f0f\u5e94\u7528\u6d4b\u8bd5\u73af\u5883\u6216\u8f7b\u91cf\u7ea7\u751f\u4ea7\u96c6\u7fa4\u3002\u540e\u7eed\u53ef\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u6269\u5c55\u8282\u70b9\u6570\u91cf\uff0c\u901a\u8fc7 Swarm \u7684\u52a8\u6001\u8c03\u5ea6\u80fd\u529b\u7075\u6d3b\u5206\u914d\u8d44\u6e90\u3002<\/p>\n","protected":false},"author":2,"featured_media":33182,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,2709,43,44],"topic":[],"class_list":["post-33183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-docker","tag-2709","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4 - \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\/33183.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb916\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u901a\u8fc7 4 \u53f0 2C2G \u670d\u52a1\u5668\u642d\u5efa\u7684 Docker Swarm \u96c6\u7fa4\uff0c\u914d\u5408 Portainer \u53ef\u89c6\u5316\u7ba1\u7406\uff0c\u5b9e\u73b0\u4e86\uff1a\u8ba1\u7b97\u8d44\u6e90\u7684\u96c6\u4e2d\u7ba1\u7406\u4e0e\u5f39\u6027\u5206\u914d\u5bb9\u5668\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u4e0e\u8d1f\u8f7d\u5747\u8861\u53ef\u89c6\u5316\u7684\u96c6\u7fa4\u76d1\u63a7\u4e0e\u4fbf\u6377\u64cd\u4f5c\u6b64\u65b9\u6848\u9002\u7528\u4e8e\u4e2d\u5c0f\u89c4\u6a21\u5fae\u670d\u52a1\u67b6\u6784\u3001\u5206\u5e03\u5f0f\u5e94\u7528\u6d4b\u8bd5\u73af\u5883\u6216\u8f7b\u91cf\u7ea7\u751f\u4ea7\u96c6\u7fa4\u3002\u540e\u7eed\u53ef\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u6269\u5c55\u8282\u70b9\u6570\u91cf\uff0c\u901a\u8fc7 Swarm \u7684\u52a8\u6001\u8c03\u5ea6\u80fd\u529b\u7075\u6d3b\u5206\u914d\u8d44\u6e90\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/33183.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-26T17:10:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250426171024-680d138075869.png\" \/>\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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/33183.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/33183.html\",\"name\":\"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-26T17:10:25+00:00\",\"dateModified\":\"2025-04-26T17:10:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/33183.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/33183.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/33183.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4\"}]},{\"@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":"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4 - \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\/33183.html","og_locale":"zh_CN","og_type":"article","og_title":"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb916\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u901a\u8fc7 4 \u53f0 2C2G \u670d\u52a1\u5668\u642d\u5efa\u7684 Docker Swarm \u96c6\u7fa4\uff0c\u914d\u5408 Portainer \u53ef\u89c6\u5316\u7ba1\u7406\uff0c\u5b9e\u73b0\u4e86\uff1a\u8ba1\u7b97\u8d44\u6e90\u7684\u96c6\u4e2d\u7ba1\u7406\u4e0e\u5f39\u6027\u5206\u914d\u5bb9\u5668\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u4e0e\u8d1f\u8f7d\u5747\u8861\u53ef\u89c6\u5316\u7684\u96c6\u7fa4\u76d1\u63a7\u4e0e\u4fbf\u6377\u64cd\u4f5c\u6b64\u65b9\u6848\u9002\u7528\u4e8e\u4e2d\u5c0f\u89c4\u6a21\u5fae\u670d\u52a1\u67b6\u6784\u3001\u5206\u5e03\u5f0f\u5e94\u7528\u6d4b\u8bd5\u73af\u5883\u6216\u8f7b\u91cf\u7ea7\u751f\u4ea7\u96c6\u7fa4\u3002\u540e\u7eed\u53ef\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u6269\u5c55\u8282\u70b9\u6570\u91cf\uff0c\u901a\u8fc7 Swarm \u7684\u52a8\u6001\u8c03\u5ea6\u80fd\u529b\u7075\u6d3b\u5206\u914d\u8d44\u6e90\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/33183.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-26T17:10:25+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250426171024-680d138075869.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/33183.html","url":"https:\/\/www.wsisp.com\/helps\/33183.html","name":"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-26T17:10:25+00:00","dateModified":"2025-04-26T17:10:25+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/33183.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/33183.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/33183.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"4 \u53f0 2C2G \u670d\u52a1\u5668\u9006\u88ad\uff01\u624b\u628a\u624b\u6559\u4f60\u7528 Docker Swarm+Portainer \u6253\u9020\u8d85\u4fbf\u6377\u96c6\u7fa4"}]},{"@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\/33183","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=33183"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/33183\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/33182"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=33183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=33183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=33183"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=33183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}