Docker Swarm Rocks (2024)

Docker Swarm Rocks (1)

Deprecation Warning 🚨¶

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. 🤓

Why?¶

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:

  • Replicability, use the same files as when developing locally.
  • Simplicity and speed for development and deployment.
  • Robustness and security, with fault-tolerant clusters.

Docker Swarm mode¶

If you have Docker installed, you already have Docker Swarm, it's integrated into Docker.

You don't have to install anything else.

Note¶

Whenever you read here "Docker Swarm" we are actually talking about "Docker Swarm mode".

Not the deprecated product called "Docker Swarm".

Alternatives¶

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.

About Docker Swarm mode¶

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).

Single server¶

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.

About Docker Swarm Rocks¶

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.

Prerequisites¶

  • To know some Linux.
  • To know some Docker.

Install and set up¶

Install a new Linux server with Docker¶

  • Create a new remote VPS ("virtual private server").
  • Deploy the latest Ubuntu LTS ("long term support") version. At the time of this writing it's Ubuntu 18.04.
  • Connect to it via SSH, e.g.:
  • Define a server name using a subdomain of a domain you own, for example dog.example.com.
  • Make sure the subdomain DNS records point to your VPS's IP address.
  • Create a temporal environment variable with the name of the host to be used later, e.g.:
export USE_HOSTNAME=dog.example.com
  • Set up the server hostname:
# Set up the server hostnameecho $USE_HOSTNAME > /etc/hostnamehostname -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.

  • Update packages:
# Install the latest updatesapt-get updateapt-get upgrade -y
  • Install Docker following the official guide...
  • ...or alternatively, run the official convenience script:
# Download Dockercurl -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 scriptrm get-docker.sh
  • If you are setting up multiple nodes (servers/VPSs), repeat these steps for each one.
    • Make sure you use a different domain/subdomain for each node.

Set up swarm mode¶

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.

  • On the main manager node, run:
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

Add manager nodes (optional)¶

  • On the main manager node, for each additional manager node you want to set up, run:
docker swarm join-token manager
  • Copy the result and paste it in the additional manager node's terminal, it will be something like:
 docker swarm join --token SWMTKN-1-5tl7yaasdfd9qt9j0easdfnml4lqbosbasf14p13-f3hem9ckmkhasdf3idrzk5gz 192.0.2.175:2377

Add worker nodes (optional)¶

  • On the main manager node, for each additional worker node you want to set up, run:
docker swarm join-token worker
  • Copy the result and paste it in the additional worker node's terminal, it will be something like:
docker swarm join --token SWMTKN-1-5tl7ya98erd9qtasdfml4lqbosbhfqv3asdf4p13-dzw6ugasdfk0arn0 192.0.2.175:2377

Check it¶

  • Check that the cluster has all the nodes connected and set up:
docker node ls

It outputs something like:

ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSIONndcg2iavasdfrm6q2qwere2rr * dog.example.com Ready Active Leader 18.06.1-ce3jrutmd3asdf1ombqwerr9svk cat.example.com Ready Active Reachable 18.06.1-cei9ec9hjasdfaoyyjqwerr3iqa snake.example.com Ready Active Reachable 18.06.1-ce

Done¶

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.

Docker Swarm Rocks (2024)

FAQs

Is Docker Swarm outdated? ›

That's because the modern "Docker Swarm mode" is easy to confuse with a separate piece of software called "Docker Swarm," which has been deprecated since 2017. You can still access Docker Swarm, now called "Swarm Classic," via GitHub.

What are the disadvantages of Docker Swarm? ›

Drawbacks of Docker swarm

Although it offers fundamental tools for scaling as well as managing containers, it might fall short in more complex use cases. There are fewer possibilities for modifying the behavior and configuration of the swarm compared to other container orchestration technologies.

Is Docker Swarm production ready? ›

You can also use Docker Swarm in production if you have a stack that is moderately low maintenance (like 3-10 nodes with less than 100 containers running). For larger workloads, Docker Swarm quickly falls behind K8s, which has better tools, support, and documentation at that scale.

Is Docker Swarm worth learning? ›

Docker Swarm is easy to learn and start with since it is lightweight and provides a simple approach to managing Docker containers. Kubernetes, however, has a much steeper learning curve since it offers more features and flexibility for deploying and managing containers.

Is Docker Swarm dead in 2024? ›

Swarm is not dead. Mirantis (Docker's parent company) uses the internals of swarm in their Kubernetes offering. And the OCI maintains (Swarmkit)[https://github.com/moby/swarmkit/] as part if the Moby project (Docker's upstream).

What is the replacement for Docker Swarm? ›

Cycle is a platform that is an alternative to Docker Swarm, Kubernetes, ECS, Cloud Run, and others.

Why we use Kubernetes instead of docker Swarm? ›

Docker Swarm is a lightweight, easy-to-use orchestration tool with limited offerings compared to Kubernetes. In contrast, Kubernetes is complex but powerful and provides self-healing, auto-scaling capabilities out of the box.

Which OS is best for docker Swarm? ›

What OS is apt for docker? Any Linux OS can be used for docker but we prefer Boot2Docker or RancherOS. There are many reasons why you would want to choose one over the other. Boot2Docker is a better choice for Windows and Mac OS X users because it provides an easy way to get started with Docker.

Is anyone using docker Swarm? ›

We have data on 7,604 companies that use Docker Swarm. The companies using Docker Swarm are most often found in United States and in the Information Technology and Services industry. Docker Swarm is most often used by companies with 50-200 employees and 10M-50M dollars in revenue.

Is it worth learning Docker in 2024? ›

In the ever-evolving tech landscape of 2024, Docker stands out as a beacon of efficiency and innovation. This blog post dives into why Docker has become an indispensable tool in the developer's toolkit and a critical skill for tech professionals. Docker, in its essence, is a containerization platform.

Does Docker Swarm do load balancing? ›

Effectively, Docker acts as a load balancer for your swarm services. You can bypass the routing mesh, so that when you access the bound port on a given node, you are always accessing the instance of the service running on that node.

Is Docker Swarm high availability? ›

A Docker Swarm setup that consists of one or two manager nodes is not considered highly available because any incident will cause operations on the cluster to be interrupted. Therefore the minimum number of manager nodes in a highly available Swarm cluster should be three.

Is Docker Swarm relevant? ›

Key Features of Docker Swarm​

It integrates seamlessly with the existing Docker API, making it a natural choice for teams already using Docker containers. Scalaing capabilities: Docker Swarm allows you to scale up or down with ease, making it a great choice for applications that need to handle varying loads.

Is Docker becoming obsolete? ›

You can actually choose from a variety of options when it comes to what software you want to use as your container runtime when running Kubernetes. Up to now, a fairly popular option was to use Docker as the container runtime. However, this will no longer be an option in the future.

What companies use Docker Swarm? ›

Companies using Docker Swarm(or used Swarm in the past)
  • Portainer.
  • Spotify.
  • PayPal.
  • The New York Times.
  • ADP.
  • Yelp.
  • Delivery Hero.
  • Hootsuite.

Top Articles
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 5688

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.