Docker Swarm mode rocks! Ideas, tools and recipes. Get a production-ready, distributed, HTTPS served, cluster in minutes, not weeks.
This website is deprecated.
It's kept around mainly for historical reasons.
See Docker Swarm Mode or Kubernetes for more information.
If you want to see alternative resources, you could check the awesome-swarm list for more resources about Docker Swarm Mode. 🤓
Docker is a great tool (the "de facto" standard) to build Linux containers.
Docker Compose is great to develop locally with Docker, in a replicable way.
Docker Swarm Mode is great to deploy your application stacks to production, in a distributed cluster, using the same files used by Docker Compose locally.
So, with Docker Swarm Mode you have:
If you have Docker installed, you already have Docker Swarm, it's integrated into Docker.
You don't have to install anything else.
Some of the main alternatives are:
To use any of them you need to learn a huge new set of concepts, configurations, files, commands, etc.
Docker Swarm mode is comparable to them.
But it, with all the ideas described here, is what I would recommend for teams of less than 200 developers, or clusters of less than 1000 machines.
This includes small / medium size organizations (like when you are not Google or Amazon), startups, one-man projects, and "hobby" projects.
Try it.
Set up a distributed cluster ready for production.
...In about 20 minutes.
If it doesn't work for you, then you can go for Kubernetes, Mesos or any other.
Those are great tools. But learning them might take weeks. So, the 20 minutes spent here are not much (and up to here you already spent 3 minutes).
With Docker Swarm mode you can start with a "cluster" of a single server.
You can set it up, deploy your applications and do everything on a $5 USD/month server.
And then, when the time to grow comes, you can add more servers to the cluster.
With a one-line command.
And you can create your applications to be ready for massive scale from the beginning, starting from a single small server.
This is not associated with Docker or any of the tools suggested here.
It's mainly a set of ideas, documentation and tools to use existing open source products efficiently together.
Ubuntu 18.04
.ssh [email protected]
dog.example.com
.export USE_HOSTNAME=dog.example.com
hostname
:# Set up the server hostname
echo $USE_HOSTNAME > /etc/hostname
hostname -F /etc/hostname
Note: If you are not a root
user, you might need to add sudo
to these commands. The shell will tell you when you don't have enough permissions. Note that sudo
does not preserve environment variables by default, but this can be enabled via the -E
flag.
# Install the latest updates
apt-get update
apt-get upgrade -y
# Download Docker
curl -fsSL get.docker.com -o get-docker.sh
# Install Docker using the stable channel (instead of the default "edge")
CHANNEL=stable sh get-docker.sh
# Remove Docker install script
rm get-docker.sh
In Docker Swarm Mode you have one or more "manager" nodes and one or more "worker" nodes (that can be the same manager nodes).
The first step is to configure one (or more) manager nodes.
docker swarm init
Note: if you see an error like:
Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on interface eth0 (198.51.100.48 and 10.19.0.5) - specify one with --advertise-addr
...select the public IP (e.g. 198.51.100.48
in this example), and run the command again with --advertise-addr
, e.g.:
docker swarm init --advertise-addr 198.51.100.48
docker swarm join-token manager
docker swarm join --token SWMTKN-1-5tl7yaasdfd9qt9j0easdfnml4lqbosbasf14p13-f3hem9ckmkhasdf3idrzk5gz 192.0.2.175:2377
docker swarm join-token worker
docker swarm join --token SWMTKN-1-5tl7ya98erd9qtasdfml4lqbosbhfqv3asdf4p13-dzw6ugasdfk0arn0 192.0.2.175:2377
docker node ls
It outputs something like:
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
ndcg2iavasdfrm6q2qwere2rr * dog.example.com Ready Active Leader 18.06.1-ce
3jrutmd3asdf1ombqwerr9svk cat.example.com Ready Active Reachable 18.06.1-ce
i9ec9hjasdfaoyyjqwerr3iqa snake.example.com Ready Active Reachable 18.06.1-ce
That's it.
You have a distributed Docker swarm mode cluster set up.
Check other sections in the documentation at https://dockerswarm.rocks to see how to set up HTTPS, you still have time, the 20 minutes are not over yet.
Then you can see how to deploy stacks, etc.
You already did the hard part, the rest is easy.