This is diagram is used to deploy the 3 nodes Docker swarm.

On three nodes: docker01, docker02, and docker03.
apt-get update

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"

Install Docker Engine
apt-get update
apt-get install docker-ce docker-ce-cli

Enable and start Docker daemon.
systemctl start docker
systemctl enable docker

+ Initialize Docker Swarm Cluster on node 1: docker01
docker swarm init --advertise-addr 192.168.5.46

Join docker02 and docker03 to the cluster.


Create a custom httpd image with the listening port is 8847.

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

+ Scale Applications on Docker Swarm to have high availability and high performance on 3 nodes.
docker service scale tunghttp=3
docker service ps tunghttp


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>


Open the web browser and access the web server via port 8847 on three Docker IP addresses.



Check three nodes.
docker node ls

Check the 8847 port is running on the Docker node.
netstat -ant | grep 8847
