This tutorial introduces you to the features of Docker Engine Swarm mode. You may want to familiarize yourself with the key concepts before you begin.
The tutorial guides you through the following activities:
This tutorial uses Docker Engine CLI commands entered on the command line of a terminal window.
If you are brand new to Docker, see About Docker Engine.
To run this tutorial, you need the following:
This tutorial requires three Linux hosts which have Docker installed and can communicate over a network. These can be physical machines, virtual machines, Amazon EC2 instances, or hosted in some other way. You can even use Docker Machine from a Linux, Mac, or Windows host. Check out Getting started - Swarms for one possible set-up for the hosts.
One of these machines is a manager (called manager1
) and two of them are workers (worker1
and worker2
).
Note: You can follow many of the tutorial steps to test single-node swarm as well, in which case you need only one host. Multi-node commands do not work, but you can initialize a swarm, create services, and scale them.
This tutorial requires Docker Engine 1.12 or newer on each of the host machines. Install Docker Engine and verify that the Docker Engine daemon is running on each of the machines. You can get the latest version of Docker Engine as follows:
If you are using Linux based physical computers or cloud-provided computers as hosts, simply follow the Linux install instructions for your platform. Spin up the three machines, and you are ready. You can test both single-node and multi-node swarm scenarios on Linux machines.
Alternatively, install the latest Docker Desktop for Mac or Docker Desktop for Windows application on one computer. 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.
The IP address must be assigned to a network interface available to the host operating system. All nodes in the swarm need to connect to the manager at the IP address.
Because other nodes contact the manager node on its IP address, you should use a fixed IP address.
You can run ifconfig
on Linux or macOS to see a list of the available network interfaces.
If you are using Docker Machine, you can get the manager IP with either docker-machine ls
or docker-machine ip <MACHINE-NAME>
— for example, docker-machine ip manager1
.
The tutorial uses manager1
: 192.168.99.100
.
The following ports must be available. On some systems, these ports are open by default.
If you plan on creating an overlay network with encryption (--opt encrypted
), you also need to ensure ip protocol 50 (ESP) traffic is allowed.
After you have set up your environment, you are ready to create a swarm.
tutorial, cluster management, swarm mode
© 2019 Docker, Inc.
Licensed under the Apache License, Version 2.0.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
https://docs.docker.com/engine/swarm/swarm-tutorial/