{"id":15337,"date":"2023-01-28T16:28:44","date_gmt":"2023-01-28T13:28:44","guid":{"rendered":"https:\/\/kifarunix.com\/?p=15337"},"modified":"2024-03-09T23:39:22","modified_gmt":"2024-03-09T20:39:22","slug":"how-to-setup-three-node-docker-swarm-cluster-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-setup-three-node-docker-swarm-cluster-on-ubuntu\/","title":{"rendered":"How to Setup Three Node Docker Swarm Cluster on Ubuntu 22.04"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1068\" height=\"598\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/01\/setup-docker-swarm-cluster-1.png\" alt=\"Setup Three Node Docker Swarm Cluster on Ubuntu\" class=\"wp-image-15356\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/01\/setup-docker-swarm-cluster-1.png?v=1674912352 1068w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/01\/setup-docker-swarm-cluster-1-768x430.png?v=1674912352 768w\" sizes=\"(max-width: 1068px) 100vw, 1068px\" \/><\/figure>\n\n\n\n<p>How can I setup a Docker swarm? In this tutorial, you will learn how to setup three node Docker <a href=\"https:\/\/docs.docker.com\/engine\/swarm\/\" target=\"_blank\" rel=\"noreferrer noopener\">swarm<\/a> cluster on Ubuntu 22.04. Docker Swarm is a cluster management and orchestration tool for Docker Engines.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#benefits-of-docker-swarm\">Benefits of Docker Swarm<\/a><\/li><li><a href=\"#setting-up-three-node-docker-swarm-on-ubuntu-22-04\">Setting up Three Node Docker Swarm on Ubuntu 22.04<\/a><ul><li><a href=\"#setup-and-configure-static-ip-addresses-on-docker-node\">Setup and Configure Static IP addresses on Docker Node<\/a><\/li><li><a href=\"#install-docker-engine-on-all-nodes\">Install Docker Engine on All Nodes<\/a><\/li><li><a href=\"#open-required-protocols-and-ports-between-swarm-nodes\">Open Required Protocols and Ports between Swarm Nodes<\/a><\/li><li><a href=\"#start-docker-engine-daemon\">Start Docker Engine Daemon<\/a><\/li><li><a href=\"#initialize-a-docker-swarm-cluster-on-manager-node\">Initialize a Docker Swarm Cluster on Manager Node<\/a><\/li><li><a href=\"#add-worker-nodes-into-docker-swarm-cluster\">Add Worker Nodes into Docker Swarm Cluster<\/a><\/li><li><a href=\"#get-docker-swarm-node-details\">Get Docker Swarm Node Details<\/a><\/li><li><a href=\"#promote-a-worker-node-to-manager-node\">Promote a Worker Node to Manager Node<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits-of-docker-swarm\">Benefits of Docker Swarm<\/h2>\n\n\n\n<p>Some benefits of using Docker Swarm include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Scalability: You can easily scale your application by adding or removing nodes from the swarm.<\/li>\n\n\n\n<li>High availability: Swarm ensures that containers are automatically rescheduled in the event of a node failure to ensure that your applications are always available.<\/li>\n\n\n\n<li>Load balancing: Swarm automatically distributes traffic to containers based on the available resources.<\/li>\n\n\n\n<li>Easy management: You can use the Docker API and command-line interface to manage your swarm, making it easy to integrate with existing tools and processes.<\/li>\n\n\n\n<li>Service Discovery: Docker swarm allows you to discover and connect to other services running in your swarm cluster.<\/li>\n\n\n\n<li>Rolling Update: Swarm allows you to perform rolling updates  to your nodes incrementally in a controlled manner.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setting-up-three-node-docker-swarm-on-ubuntu-22-04\">Setting up Three Node Docker Swarm on Ubuntu 22.04<\/h2>\n\n\n\n<p>First of all, in a Docker swarm cluster environment, there exists different concepts;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Docker Node:<\/strong> this is a host running Docker engine. It can be a physical or virtual machine. A Docker node can run as a manager node, worker node or both.<\/li>\n\n\n\n<li><strong>Manager Node<\/strong>: These are the nodes run orchestration and cluster management functions. They are responsible for maintaining the desired state of the swarm. They dispatch units of work called&nbsp;tasks&nbsp;to worker nodes.\n<ul class=\"wp-block-list\">\n<li>Note that <em>by default manager nodes also act as a worker nodes. This means the scheduler can assign tasks to a manager node.<\/em><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Worker Node<\/strong>: These are the nodes that receive and execute tasks dispatched from the manager nodes.<\/li>\n\n\n\n<li><strong>Tasks<\/strong>: A&nbsp;task&nbsp;is a running container which is part of a swarm service and managed by a swarm manager.<\/li>\n\n\n\n<li><strong>Service<\/strong>: A&nbsp;service&nbsp;is the definition of the tasks to execute on the manager or worker nodes.<\/li>\n<\/ul>\n\n\n\n<p>In this setup, we have three Nodes;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Node<\/strong><\/td><td><strong>IP Address<\/strong><\/td><td><strong>Role of the Node<\/strong><\/td><\/tr><tr><td>swarm01<\/td><td>192.168.10.10<\/td><td>manager, worker<\/td><\/tr><tr><td>swarm02<\/td><td>192.168.10.20<\/td><td>worker<\/td><\/tr><tr><td>swarm03<\/td><td>192.168.10.30<\/td><td>worker<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"setup-and-configure-static-ip-addresses-on-docker-node\">Setup and Configure Static IP addresses on Docker Node<\/h3>\n\n\n\n<p>Ensure that you configure static IP addresses on your Docker swarm cluster nodes.<\/p>\n\n\n\n<p>See how to configure static IP addresses using Netplan on Ubuntu systems;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-static-ip-addresses-using-netplan-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure Static IP Addresses using Netplan on Ubuntu<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-docker-engine-on-all-nodes\">Install Docker Engine on All Nodes<\/h3>\n\n\n\n<p>You need Docker engine installed on all nodes you intend to set them up as a swarm.<\/p>\n\n\n\n<p>Since we are using Ubuntu 22.04 nodes in this guide, you can follow the link below to learn how to install and <\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-docker-ce-on-ubuntu-20-04\/\">Install Docker CE on Ubuntu<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"open-required-protocols-and-ports-between-swarm-nodes\">Open Required Protocols and Ports between Swarm Nodes<\/h3>\n\n\n\n<p>If you have firewall running on the Docker swarm cluster nodes, there are ports and protocols you need to allow between the swarm nodes;<\/p>\n\n\n\n<p>These include;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>TCP port 2377<\/strong>&nbsp;for cluster management communications<\/li>\n\n\n\n<li><strong>TCP<\/strong>&nbsp;and&nbsp;<strong>UDP port 7946<\/strong>&nbsp;for communication among nodes<\/li>\n\n\n\n<li><strong>UDP port 4789<\/strong>&nbsp;for overlay network traffic<\/li>\n\n\n\n<li><strong>IP Protocol 50 (ESP)<\/strong> which is only applicable if you plan on&nbsp;creating an overlay network with encryption (<code>--opt encrypted<\/code>).<\/li>\n<\/ul>\n\n\n\n<p>To open these ports\/protocols, for example on nodes running Ubuntu;<\/p>\n\n\n\n<p>On swarm01 node, to allow both swarm02 and swarm03;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in 192.168.10.20 192.168.10.30; do ufw allow from $i to any port 2377 proto tcp; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in 192.168.10.20 192.168.10.30; do ufw allow from $i to any port 7946 proto tcp; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in 192.168.10.20 192.168.10.30; do ufw allow from $i to any port 7946 proto udp; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in 192.168.10.20 192.168.10.30; do ufw allow from $i to any port 4789 proto udp; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in 192.168.10.20 192.168.10.30; do ufw allow from $i to any proto esp; done<\/code><\/pre>\n\n\n\n<p>Do the same on other nodes, replacing the source IP addresses accordingly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"start-docker-engine-daemon\">Start Docker Engine Daemon<\/h3>\n\n\n\n<p>On all the Docker swarm cluster nodes, ensure Docker service is running;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl is-active docker<\/code><\/pre>\n\n\n\n<p>Output should be <strong><code>active<\/code><\/strong>. Otherwise, start and enable Docker service to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now docker<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"initialize-a-docker-swarm-cluster-on-manager-node\">Initialize a Docker Swarm Cluster on Manager Node<\/h3>\n\n\n\n<p>It is now time to create and initialize a Docker swarm. Thus, login to Manager node and create a swarm.<\/p>\n\n\n\n<p>Docker swarm can be controlled via the <strong><code>docker swarm<\/code><\/strong> command.<\/p>\n\n\n\n<p>To see command line usage\/help, run;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm --help<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Usage:  docker swarm COMMAND\n\nManage Swarm\n\nCommands:\n  ca          Display and rotate the root CA\n  init        Initialize a swarm\n  join        Join a swarm as a node and\/or manager\n  join-token  Manage join tokens\n  leave       Leave the swarm\n  unlock      Unlock swarm\n  unlock-key  Manage the unlock key\n  update      Update the swarm\n\nRun 'docker swarm COMMAND --help' for more information on a command.\n<\/code><\/pre>\n\n\n\n<p>Thus, to initialize a Docker swarm, simply use <strong><code>docker swarm init<\/code><\/strong> as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm init --advertise-addr &lt;ip|interface&gt;&#91;:port]<\/code><\/pre>\n\n\n\n<p>Where IP is the Manager node&#8217;s IP address that will be reachable by other swarm nodes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm init --advertise-addr 192.168.10.10<\/code><\/pre>\n\n\n\n<p>The command will initialize a swarm and set the current node as the Manager.<\/p>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>Swarm initialized: current node (imt55exvbkyo2zzdq2xn2ebxl) is now a manager.\n\nTo add a worker to this swarm, run the following command:\n\n    docker swarm join --token SWMTKN-1-358ntjh2bqw4jrcxq6wlch73yor6csqa3l050h3dgspxq6ti3x-ejhwnh99irv0rudgvgezm59qd 192.168.10.10:2377\n\nTo add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.\n\n<\/code><\/pre>\n\n\n\n<p>First node, which is manager node has now been created. You can list Docker swarm nodes using the command;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node ls<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-sz\"><code>ID                            HOSTNAME   STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION\nimt55exvbkyo2zzdq2xn2ebxl *   swarm01    Ready     Active         Leader           20.10.22\n<\/code><\/pre>\n\n\n\n<p>You can also use the command below to get status of swarm;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker info<\/code><\/pre>\n\n\n\n<p>If you loose the swarm cluster join token, you can always display using <strong><code>docker swarm join-token<\/code><\/strong> option.<\/p>\n\n\n\n<p>For example, to show the manager join token;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm join-token manager<\/code><\/pre>\n\n\n\n<pre class=\"scroll-sz\"><code>To add a manager to this swarm, run the following command:\n\n    docker swarm join --token SWMTKN-1-358ntjh2bqw4jrcxq6wlch73yor6csqa3l050h3dgspxq6ti3x-26km5yegdozlcq1lxno23x0w0 192.168.10.10:2377\n\n\n<\/code><\/pre>\n\n\n\n<p>To show just the token only;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm join-token -q manager<\/code><\/pre>\n\n\n\n<p>To show the worker join token;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm join-token worker<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-sz\"><code>To add a worker to this swarm, run the following command:\n\n    docker swarm join --token SWMTKN-1-358ntjh2bqw4jrcxq6wlch73yor6csqa3l050h3dgspxq6ti3x-ejhwnh99irv0rudgvgezm59qd 192.168.10.10:2377\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-worker-nodes-into-docker-swarm-cluster\">Add Worker Nodes into Docker Swarm Cluster<\/h3>\n\n\n\n<p>Next, to make the cluster whole, you need to add worker nodes into it.<\/p>\n\n\n\n<p>As mentioned above, we will use our swarm01 as both manager and worker node. <em>By default manager nodes also act as a worker nodes. This means the scheduler can assign tasks to a manager node.<\/em><\/p>\n\n\n\n<p>Add swarm02 into Docker swarm<\/p>\n\n\n\n<p>Login to swarm02 node or whatever your second node is and add it to the swarm cluster.<\/p>\n\n\n\n<p>The command to use to add worker nodes into the swarm cluster is given when you initialize a swarm.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@swarm02:~# <strong>docker swarm join \\\n--token SWMTKN-1-358ntjh2bqw4jrcxq6wlch73yor6csqa3l050h3dgspxq6ti3x-ejhwnh99irv0rudgvgezm59qd \\\n192.168.10.10:2377<\/strong><\/code><\/pre>\n\n\n\n<p>If the command above successfully runs, you should see such an output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>This node joined a swarm as a worker.<\/code><\/pre>\n\n\n\n<p>Similarly, add your third node, in this example setup is swarm03 into the cluster;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@swarm03:~# <strong>docker swarm join \\\n--token SWMTKN-1-358ntjh2bqw4jrcxq6wlch73yor6csqa3l050h3dgspxq6ti3x-ejhwnh99irv0rudgvgezm59qd \\\n192.168.10.10:2377<\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"get-docker-swarm-node-details\">Get Docker Swarm Node Details<\/h3>\n\n\n\n<p>Docker provides various commands that you can use to get various information about the nodes on the swarm cluster.<\/p>\n\n\n\n<p>The command is;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node<\/code><\/pre>\n\n\n\n<p>For example, you can list the available nodes on the swarm cluster;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node ls<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>ID                            HOSTNAME   STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION\nimt55exvbkyo2zzdq2xn2ebxl *   swarm01    Ready     Active         Leader           20.10.22\nyzp9ppjxte94w3hk1bvy1bc6p     swarm02    Ready     Active                          20.10.12\nejtziqfxfk1gsvt11x8edo22d     swarm03    Ready     Active                          20.10.22\n<\/code><\/pre>\n\n\n\n<p>All the three nodes in the swarm now with swarm01 being the leader! You have now setup three node Docker swarm cluster.<\/p>\n\n\n\n<p>The <strong><code>* (asterisk)<\/code><\/strong> adjacent to the node ID shows the node you are currently connected to.<\/p>\n\n\n\n<p>Some of the swarm services\/nodes state;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>Ready<\/code><\/strong>: The node is available and ready to accept tasks.<\/li>\n\n\n\n<li><strong><code>Disconnected<\/code><\/strong>: The node has been disconnected from the swarm, but is still running.<\/li>\n\n\n\n<li><strong><code>Pending<\/code><\/strong>: The node is being added to the swarm but is not yet ready to accept tasks.<\/li>\n\n\n\n<li><strong><code>Down<\/code><\/strong>: The node is down and not accepting tasks.<\/li>\n\n\n\n<li><strong><code>Unknown<\/code><\/strong>: The node&#8217;s status is not known, usually caused by a network error or other connectivity issues.<\/li>\n\n\n\n<li><strong><code>Drain<\/code><\/strong>: The node has been drained, meaning that it is not accepting new tasks, but existing tasks will continue to run until completion.<\/li>\n\n\n\n<li><strong><code>Active<\/code><\/strong>: The scheduler can assign tasks to the node.<\/li>\n\n\n\n<li><strong><code>Pause<\/code>&nbsp;<\/strong>: No new tasks can be assigned to the node by the scheduler, but existing tasks remain running.<\/li>\n\n\n\n<li><strong><code>Leader<\/code><\/strong>: The node is the current primary manager node that makes all swarm management and orchestration decisions for the swarm.<\/li>\n\n\n\n<li><code><strong>Reachable<\/strong><\/code>: Is a secondary manager that is eliogible to become a primary manager in case the leader node becomes unavailable.<\/li>\n\n\n\n<li><code><strong>Unavailable<\/strong><\/code>: The node is a manager but it can\u2019t communicate with other managers in the cluster.<\/li>\n<\/ul>\n\n\n\n<p>You can also get a detailed information on one or more nodes;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node inspect &lt;node-name&gt;<\/code><\/pre>\n\n\n\n<p>e.g<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node inspect swarm03<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>[\n    {\n        \"ID\": \"ejtziqfxfk1gsvt11x8edo22d\",\n        \"Version\": {\n            \"Index\": 20\n        },\n        \"CreatedAt\": \"2023-01-28T10:58:56.486765341Z\",\n        \"UpdatedAt\": \"2023-01-28T10:58:56.561125458Z\",\n        \"Spec\": {\n            \"Labels\": {},\n            \"Role\": \"worker\",\n            \"Availability\": \"active\"\n        },\n        \"Description\": {\n            \"Hostname\": \"swarm03\",\n            \"Platform\": {\n                \"Architecture\": \"x86_64\",\n                \"OS\": \"linux\"\n            },\n            \"Resources\": {\n                \"NanoCPUs\": 2000000000,\n                \"MemoryBytes\": 2071773184\n            },\n            \"Engine\": {\n                \"EngineVersion\": \"20.10.22\",\n                \"Plugins\": [\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"awslogs\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"fluentd\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"gcplogs\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"gelf\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"journald\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"json-file\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"local\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"logentries\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"splunk\"\n                    },\n                    {\n                        \"Type\": \"Log\",\n                        \"Name\": \"syslog\"\n                    },\n                    {\n                        \"Type\": \"Network\",\n                        \"Name\": \"bridge\"\n                    },\n                    {\n                        \"Type\": \"Network\",\n                        \"Name\": \"host\"\n                    },\n                    {\n                        \"Type\": \"Network\",\n                        \"Name\": \"ipvlan\"\n                    },\n                    {\n                        \"Type\": \"Network\",\n                        \"Name\": \"macvlan\"\n                    },\n                    {\n                        \"Type\": \"Network\",\n                        \"Name\": \"null\"\n                    },\n                    {\n                        \"Type\": \"Network\",\n                        \"Name\": \"overlay\"\n                    },\n                    {\n                        \"Type\": \"Volume\",\n                        \"Name\": \"local\"\n                    }\n                ]\n            },\n            \"TLSInfo\": {\n                \"TrustRoot\": \"-----BEGIN CERTIFICATE-----\\nMIIBajCCARCgAwIBAgIUU\/SWwBZeMD4eXlmeJQKuKjlghK4wCgYIKoZIzj0EAwIw\\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMjMwMTI4MDkzOTAwWhcNNDMwMTIzMDkz\\nOTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\\nA0IABODAkPhhZZtB4nyI94gpSoKfzEYUOFtYa0K7bR2Y75fAfpC0YCwgqkh\/KQi9\\nQ5Y21sGspeOiqzJb+Ai\/GObTPHSjQjBAMA4GA1UdDwEB\/wQEAwIBBjAPBgNVHRMB\\nAf8EBTADAQH\/MB0GA1UdDgQWBBR3p6FR2jgVw3H3jRut8cHFxL4KPDAKBggqhkjO\\nPQQDAgNIADBFAiB0BCjJCUDsrELEZwFmGCwUZVENBJTuE57VwGZ0J\/JvAwIhANM5\\nlrJQwekBjATSJoYNvXwGnfjEwZhB3F1ZIfP3XOtH\\n-----END CERTIFICATE-----\\n\",\n                \"CertIssuerSubject\": \"MBMxETAPBgNVBAMTCHN3YXJtLWNh\",\n                \"CertIssuerPublicKey\": \"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4MCQ+GFlm0HifIj3iClKgp\/MRhQ4W1hrQrttHZjvl8B+kLRgLCCqSH8pCL1DljbWwayl46KrMlv4CL8Y5tM8dA==\"\n            }\n        },\n        \"Status\": {\n            \"State\": \"ready\",\n            \"Addr\": \"192.168.10.30\"\n        }\n    }\n]\n<\/code><\/pre>\n\n\n\n<p>for more commands, check;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node --help<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"promote-a-worker-node-to-manager-node\">Promote a Worker Node to Manager Node<\/h3>\n\n\n\n<p>How do I promote a worker to manager in docker Swarm? Yes, it is possible to promote a worker node into a manager node in docker swarm cluster. Having multiple docker swarm manager nodes ensures that if a leader manager fails for some reasons, another Manager in the cluster can assume the managerial roles of scheduling and re-balance tasks to match the desired state.<\/p>\n\n\n\n<p>So, to promote a node, use the command <strong><code>docker node promote &lt;NODE1 NODE2 NODEN&gt;<\/code><\/strong>, where NODEN is the hostname current node in the cluster. This command has to be executed on the manager node.<\/p>\n\n\n\n<p>For example, this commands promotes swarm worker node swarm02 into manager node.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node promote swarm02<\/code><\/pre>\n\n\n\n<p>You can confirm that the node is now a manager;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node ls<\/code><\/pre>\n\n\n\n<pre class=\"scroll-sz\"><code>ID                            HOSTNAME   STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION\nimt55exvbkyo2zzdq2xn2ebxl *   swarm01    Ready     Active         Leader           20.10.22\nyzp9ppjxte94w3hk1bvy1bc6p     swarm02    Ready     Active         Reachable        20.10.12\nejtziqfxfk1gsvt11x8edo22d     swarm03    Ready     Active                          20.10.22\n<\/code><\/pre>\n\n\n\n<p>Similarly, you can demote a node from manager to just a worker using <strong><code>docker node demote<\/code><\/strong> command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker node demote swarm02<\/code><\/pre>\n\n\n\n<p>You can also remove a node from the cluster by running the command, <strong><code>docker swarm leave<\/code><\/strong>, on the same node you are removing from cluster.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-deploy-wordpress-as-a-docker-container\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Deploy WordPress as a Docker Container<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-install-docker-resource-usage-extension\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Install Docker Resource Usage Extension<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can I setup a Docker swarm? In this tutorial, you will learn how to setup three node Docker swarm cluster on Ubuntu 22.04. Docker<\/p>\n","protected":false},"author":10,"featured_media":15355,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,1076,1077,36],"tags":[],"class_list":["post-15337","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-containers","category-docker","category-virtualization","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/15337"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=15337"}],"version-history":[{"count":16,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/15337\/revisions"}],"predecessor-version":[{"id":20672,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/15337\/revisions\/20672"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/15355"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=15337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=15337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=15337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}