Docker Swarm Cluster Setup



Estimated reading time: 3 minutes

Docker (01) Install Docker (02) Add Container images (03) Access to Container Services (04) Use Dockerfile (05) Use Persistent Storage (06) Use Docker-Registry (07) Use Docker-Registry (Auth) (08) Use Docker Compose (09) Configure Docker Swarm; Kubernetes (01) Minikube: Install (02) Minikube: Deploy Pods (03) Kubeadm: Install (04) Kubeadm. Docker is an open-source project that automates the deployment of applications inside software containers. Docker provides an additional layer of abstraction and automation of operating-system-level virtualization on Linux. This Quiz is created for you to test out your skills and learn what you don't know already. So, let's get started. With over half a million regular users, it’s a powerful, open-source toolset that allows you to easily build and manage containers in Docker, Swarm, Kubernetes and Azure ACI. Portainer works by hiding the complexity that makes managing containers hard, behind an easy to use GUI.

This tutorial introduces you to the features of Docker Engine Swarm mode. Youmay want to familiarize yourself with the key conceptsbefore you begin.

The tutorial guides you through the following activities:

  • initializing a cluster of Docker Engines in swarm mode
  • adding nodes to the swarm
  • deploying application services to the swarm
  • managing the swarm once you have everything running

This tutorial uses Docker Engine CLI commands entered on the command line of aterminal window.

If you are brand new to Docker, see About Docker Engine.

Set up

To run this tutorial, you need the following:

Three networked host machines

This tutorial requires three Linux hosts which have Docker installed and cancommunicate over a network. These can be physical machines, virtual machines,Amazon EC2 instances, or hosted in some other way. You can even use Docker Machinefrom a Linux, Mac, or Windows host. Check outGetting started - Swarmsfor one possible set-up for the hosts.

One of these machines is a manager (called manager1) and two of them areworkers (worker1 and worker2).

Note: You can follow many of the tutorial steps to test single-node swarmas well, in which case you need only one host. Multi-node commands do notwork, but you can initialize a swarm, create services, and scale them.

Install Docker Engine on Linux machines

If you are using Linux based physical computers or cloud-provided computers ashosts, simply follow the Linux install instructionsfor your platform. Spin up the three machines, and you are ready. You can test bothsingle-node and multi-node swarm scenarios on Linux machines.

Docker Swarm Cluster Setup Commands

Use Docker Desktop for Mac or Docker Desktop for Windows

Alternatively, install the latest Docker Desktop for Mac orDocker Desktop for Windows application on onecomputer. You can test both single-node and multi-node swarm from this computer,but you need to use Docker Machine to test the multi-node scenarios.

  • You can use Docker Desktop for Mac or Windows to test single-node featuresof swarm mode, including initializing a swarm with a single node, creatingservices, and scaling services.
  • Currently, you cannot use Docker Desktop for Mac or Docker Desktop for Windowsalone to test a multi-node swarm, but many examples are applicable to asingle-node Swarm setup.
Docker Swarm Cluster Setup

The IP address of the manager machine

Docker Swarm Cluster Setup Github

The IP address must be assigned to a network interface available to the hostoperating system. All nodes in the swarm need to connect to the manager atthe IP address.

Because other nodes contact the manager node on its IP address, you should use afixed IP address.

You can run ifconfig on Linux or macOS to see a list of theavailable network interfaces.

If you are using Docker Machine, you can get the manager IP with eitherdocker-machine ls or docker-machine ip <MACHINE-NAME> — for example,docker-machine ip manager1.

The tutorial uses manager1 : 192.168.99.100.

Open protocols and ports between the hosts

Docker Swarm Cluster Setup Windows 10

The following ports must be available. On some systems, these ports are open by default.

Swarm
  • TCP port 2377 for cluster management communications
  • TCP and UDP port 7946 for communication among nodes
  • UDP port 4789 for overlay network traffic

If you plan on creating an overlay network with encryption (--opt encrypted),you also need to ensure ip protocol 50 (ESP) traffic is allowed.

What’s next?

Setup docker swarm cluster linux

After you have set up your environment, you are ready to create a swarm.

Cluster

Docker Swarm Install Cluster

tutorial, cluster management, swarm mode