{"id":646,"date":"2023-02-26T13:37:56","date_gmt":"2023-02-26T05:37:56","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=646"},"modified":"2023-04-29T19:57:29","modified_gmt":"2023-04-29T11:57:29","slug":"docker-uses-swarm-to-create-a-cluster","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/docker-uses-swarm-to-create-a-cluster\/","title":{"rendered":"Docker\u4f7f\u7528swarm\u521b\u5efa\u96c6\u7fa4"},"content":{"rendered":"<h2>\u521d\u59cb\u5316\u96c6\u7fa4<\/h2>\n<pre><code>docker swarm init --advertise-addr &lt;MANAGER-IP&gt;<\/code><\/pre>\n<p><!-- more --><\/p>\n<pre><code>$ docker swarm init --advertise-addr 192.168.99.101  \/\/\u521d\u59cb\u5316\u7ba1\u7406\u8282\u70b9\nSwarm initialized: current node (e3nzsw54azshg1clkiithvl9f) is now a manager.\n\nTo add a worker to this swarm, run the following command:\n\n    docker swarm join \\\n    --token SWMTKN-1-2d3t6j9lub3c54lptjokjampxh1vxuu0rq78bfdmegbd9566yb-7oyake9bnhg448pf24m9cfsf8 \\\n    192.168.99.101:2377\n\nTo add a manager to this swarm, run &#039;docker swarm join-token manager&#039; and follow the instructions.<\/code><\/pre>\n<h2>\u6dfb\u52a0\u5de5\u4f5c\u8282\u70b9\u5230\u96c6\u7fa4<\/h2>\n<p>\uff081\uff09\u5728\u5de5\u4f5c\u8282\u70b9\u8fdb\u884c\u6dfb\u52a0<\/p>\n<pre><code>$ docker swarm join \\\n      --token SWMTKN-1-2d3t6j9lub3c54lptjokjampxh1vxuu0rq78bfdmegbd9566yb-7oyake9bnhg448pf24m9cfsf8 \\\n      192.168.99.101:2377\nThis node joined a swarm as a worker.<\/code><\/pre>\n<p>\uff082\uff09\u5728\u7ba1\u7406\u8282\u70b9\u8fdb\u884c\u6dfb\u52a0<\/p>\n<pre><code>$ docker swarm join-token worker<\/code><\/pre>\n<h2>\u5217\u51fa\u96c6\u7fa4\u8282\u70b9<\/h2>\n<p>\u5728\u7ba1\u7406\u8282\u70b9manager\u8f93\u5165<\/p>\n<pre><code>$ docker node ls\nID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS\ne3nzsw54azshg1clkiithvl9f *  manager   Ready   Active        Leader\ni3pnnzfmi0wpxvuptlu3z9cqj    worker    Ready   Active <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u59cb\u5316\u96c6\u7fa4 docker swarm init &#8211;advertise-addr &lt;MANAGER-IP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-646","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=646"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/646\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}