-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started Guide
Welcome to the clustering-with-docker wiki!
-
Set up Debian server VMs in Virtualbox.
Steps to be followed
- Set up the Docker Repository
Update the apt package index.
$ sudo apt-get update
Install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add –
command to set up the stable repository:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
- Install Docker Engine-Community
Update the apt package index.
$ sudo apt-get update
Install the latest version of Docker Engine - Community and containerd.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Verify that Docker Engine - Community is installed correctly by running the hello-world image.
$ sudo docker run hello-world
To use Docker as a non-root user:
$ sudo usermod -aG docker username
Docker-compose is a tool for defining and running multi-container docker applications using '.yml' file on a single docker host.
Steps to be followed:
Run this command to download the current stable release of Docker Compose:
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Allow executable permissions to the binary:
$ sudo chmod +x /usr/local/bin/docker-compose
Test the installation.
$ docker-compose --version
Deploying a Docker Swarm cluster
-
Docker Swarm is a native clustering system for Docker. It manages multiple Docker hosts participating in the cluster behave as a single virtual host. It consists of multiple Docker hosts that run in swarm mode, acting as either manager or workers or performing both roles. In Docker 1.12 and higher, Swarm mode is integrated with Docker Engine. For swarm cluster creation, the following ports must be available.
- TCP port 2377 for cluster management communications
- TCP and UDP port 7946 for communication among nodes
- UDP port 4789 for overlay network traffic
How to initialize a Docker Swarm
Open a terminal and run below command in the machine which is required to run as manager i.e. Manager node initializes a swarm cluster.
$ docker swarm init --advertise-addr 192.xxx.xxx.xxx:2377
Swarm initialized: current node (ljzebxs4pqufumo7i417t4fg3) is now a manager.
To add a worker to this swarm, run the following command:
$docker swarm join --token SWMTKN-1-0h7mj6yt0jhxxhd35vldz28uceixca0o0m54dcd9pnzz3y6vtl- 377krhkekcxvwccgyv18x7x3a 192.xxx.xxx.xxx:2377
The “--advertise-addr” flag configures the manager node to publish its address as 192.xxx.xxx.xxx. The other nodes in the swarm must be able to access the manager at the IP address.
Follow the below instructions and run the command on a Docker host to create a worker node.
$ docker swarm join --token SWMTKN-1-0h7mj6yt0jhxxhd35vldz28uceixca0o0m54dcd9pnzz3y6vtl-377krhkekcxvwccgyv18x7x3a 192.xxx.xxx.xxx:2377
Use the below command to view information about swarm nodes:
$ docker node ls
A node can leave the swarm or can be removed only by a manager node.
$ docker swarm leave (worker node leaving swarm; for manager node, use '-f' option)
$ docker node rm node-id (manager removing a worker node)