This is diagram is used to deploy the 3 nodes Docker swarm.
![](https://tungle.ca/wp-content/uploads/2022/03/image-274.png)
On three nodes: docker01, docker02, and docker03.
apt-get update
![](https://tungle.ca/wp-content/uploads/2022/03/1-2-1024x401.png)
Install Docker CE on Debian 10.
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Add Docker GPG key and Docker repository.
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
![](https://tungle.ca/wp-content/uploads/2022/03/4-3-1024x119.png)
Install Docker Engine
apt-get update
apt-get install docker-ce docker-ce-cli
![](https://tungle.ca/wp-content/uploads/2022/03/5-2.png)
Enable and start Docker daemon.
systemctl start docker
systemctl enable docker
![](https://tungle.ca/wp-content/uploads/2022/03/6-2.png)
+ Initialize Docker Swarm Cluster on node 1: docker01
docker swarm init --advertise-addr 192.168.5.46
![](https://tungle.ca/wp-content/uploads/2022/03/7-2-1024x199.png)
Join docker02 and docker03 to the cluster.
![](https://tungle.ca/wp-content/uploads/2022/03/8-2-1024x175.png)
![](https://tungle.ca/wp-content/uploads/2022/03/9-2-1024x164.png)
Create a custom httpd image with the listening port is 8847.
![](https://tungle.ca/wp-content/uploads/2022/03/10-2.png)
We can check if the worker nodes have joined to cluster successfully using the command below:
docker node ls
+ Deploy Applications on Docker Swarm
Below is an example to deploy an Apache web service with the listening port is 8847 and service name is tunghttp
docker service create --name tunghttp -p 8847:80 httpd
![](https://tungle.ca/wp-content/uploads/2022/03/10-3.png)
+ Scale Applications on Docker Swarm to have high availability and high performance on 3 nodes.
docker service scale tunghttp=3
docker service ps tunghttp
![](https://tungle.ca/wp-content/uploads/2022/03/11-3.png)
![](https://tungle.ca/wp-content/uploads/2022/03/12-2.png)
Create a new index.html file on the docker host. Then, copy the file to the Apache webserver directory as a screenshot below.
<html>
<head>
<title>Tung A01</title>
</head>
<body>
<h1 Welcome to the web server that is deployed by Docker </h1>
<img src="http://imagefromtheinternet.jpg">
</body>
</html>
![](https://tungle.ca/wp-content/uploads/2022/03/13-2-1024x226.png)
![](https://tungle.ca/wp-content/uploads/2022/03/14-3-1024x184.png)
Open the web browser and access the web server via port 8847 on three Docker IP addresses.
![](https://tungle.ca/wp-content/uploads/2022/04/image-90.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-91.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-92.png)
Check three nodes.
docker node ls
![](https://tungle.ca/wp-content/uploads/2022/03/image-399-1024x154.png)
Check the 8847 port is running on the Docker node.
netstat -ant | grep 8847
![](https://tungle.ca/wp-content/uploads/2022/03/22-2.png)