How do deploy a Docker Swarm on Ubuntu 22.04

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y.
Finally, we can install the most recent variation of the Docker engine:.
sudo apt-get updatesudo apt-get install docker-ce docker-ce-cli containerd.io -y.
To end up things up, add your user to the docker group with the command:.
sudo usermod -aG docker $USER.
Log out and log back in for the changes to work.
How to alter the hostname on your servers.
Lets alter the host names of your Docker Swarm servers. This will be done on all nodes. Well configure them as docker2, docker3 and docker1, however you can name them whatever you like.
To set the hostname, the command is:.
sudo hostnamectl set-hostname HOSTNAME.
Where HOSTNAME is the name of the host for the machine.
How to map the hosts file.
This is also done on every node. Open the hosts submit with the command:.
sudo nano/ etc/hosts.
At the bottom of the file, youll map each host like so (altering the entries to match your hostnames and IP addresses):.
192.168.1.60 docker1192.168.1.61 docker2192.168.1.62 docker3.
Close the file and conserve.
How to initialize the Swarm.
Go to the controller node (docker1) and initialize the Swarm with the command, ensuring to modify the IP address to match your requirements:.
docker swarm init– advertise-addr 192.168.1.60.
You must then be presented with a sign up with command that looks something like this:.
docker swarm sign up with– token SWMTKN-1-05rgkgq9hgvas7wfglzrumxymzxw3downs1afcbdr9kc7hq4cm-8ku8kxjsq57l1xnkl5lzjppro 192.168.1.60:2377.
Run that command on each of your nodes. Once theyve signed up with, you can confirm the Swarm on the controller node with the command:.
docker node ls.
You should see something like this in the output:.
You can
keep adding including brand-new as needed for even more scaling and failover capabilityAbility Subscribe to TechRepublics How To Make Tech Work on YouTube for all the most current tech advice for company pros from Jack Wallen.

Jack Wallen reveals you how to create a cluster of Docker servers, called a Swarm, on Ubuntu Server 22.04.

Must-read designer protection.

Docker is my go-to container implementation runtime engine. Doing so on a single Docker server would be a difficulty. To that end, you release several Docker circumstances and cluster them together. That, my good friends, is called a Docker Swarm.
Lets alter the host names of your Docker Swarm servers.

Image: monsitj/Adobe Stock
Docker is my go-to container deployment runtime engine. With it, I can rapidly release containers to a network that are quickly accessible. What takes place when I wish to be able to scale those applications? Doing so on a single Docker server would be an obstacle. To that end, you deploy multiple Docker circumstances and cluster them together. That, my good friends, is called a Docker Swarm.
SEE: Hiring kit: Back-end Developer (TechRepublic Premium).
Let me show you how to release a Docker Swarm on my de facto standard server circulation, Ubuntu. There are several moving parts involved, so lets get to it.
What youll require to release a Docker Swarm.
Im going to show with a three-node cluster (one controller and 2 nodes). For that, youll require 3 instances of Ubuntu Server 22.04. Youll also need a user with sudo benefits.
How to set up the current variation of Docker.
Youll want to do this on every node for your Swarm.
Include the Docker GPG secret with the command:.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo gpg– dearmor -o/ usr/share/keyrings/ docker-archive-keyring. gpg.
Next, add the main Docker repository:.
sudo tee/ etc/apt/sources. list.d/ docker.list > >/ dev/null. Well next install a couple of dependences with the command:.

Share:

Leave a Comment