You Need To Learn Docker Swarm!


You Need To Learn Docker Swarm!

Ever felt like you're overcomplicating your container deployments?

You might be.

Today, we're diving into a Docker orchestrator that's likely already on your machine (run `docker service` for a second will ya?), but you're probably overlooking: Docker Swarm.

The Underdog Orchestrator

For years (for me, the past 11 years to be exact), the path has seemed to be either simple Docker Compose or the more, WAY MORE complex, Kubernetes.

Compose is great for local development but falls short when scaling, especially when you have more than one machine, and production system doesn't? Heck, I don't know of one serious home lab running one node.

Kubernetes, while powerful, can be overkill for smaller projects.

But what if there was a middle ground?

I remember asking my mentor years ago about the best container deployment options.

He told me, and I quote:

"People tend to develop emotions to technology... but remember: there's no best, there's better, there's worse, sure, but the most important rule is using the right tool for the task at hand."

This stuck with me and led me to explore alternatives whenever possible, regardless of what common wisdom says. In a way, it's the tech version of "question everything".

Docker Swarm offers a sweet spot.

It's incredibly easy to use, lets you scale, load balance applications, self-heal, manage secrets, collect logs, and much more.

It's perfect for local use, home labs, and even production systems that require a few simple nodes and a straightforward deployment.

Plus, it's fully compatible with your existing Compose files!

Solving the Orchestration Problem

Scaling and managing containerized applications can be a headache, especially when running local home lab, or small scale production deployments.

Most people jump straight to Kubernetes, even for smaller projects.

If you pick a K8s SaaS, like AWS's, Google or Azure, you're going to not only pay for the pleasure of having a managed control plane, you'd have to hone the skills of Kubernetes which cannot, and should not be taken lightly.

Docker Swarm offers a simpler, lightweight solution for many use cases.

If you have you compose file ready, Docker Stack will cover all the requirements you have.

If you don't, I bet that with zero knowledge, you'll have your containers running in a remote cluster in a matter of a couple of hours.

Getting Started with Swarm

Setting up a Swarm cluster is surprisingly easy.

Locally, I'm using Lima VM to self-host machines.

You'll need a manager node (the leader) and worker nodes. Swarm makes cluster setup incredibly easy, mostly through its CLI.

To initialize a swarm cluster, use the following command:

docker swarm init --advertise-addr

This command will return a command to join worker nodes to the swarm.

To add worker nodes to the swarm, use the command returned by the init command on the manager node.

Once the cluster is set up, you can create services.

A service in Swarm is a containerized application deployed and managed within the cluster.

This enables automated scaling, load balancing, and fault tolerance.

To create a simple service with 2 replicas that runs an Alpine linux box pinging docker.com:

docker service create --replicas 2 --name my-app alpine ping docker.com

You can scale the service using:

docker service scale my-app=5

This command scales "my-app" to five replicas. Swarm takes care of the rest.

Swarm also has rolling updates. If you create a service that uses an older image, you can update it using:

docker service update --image


Putting it into Action

Think of Docker Swarm as the "Goldilocks" of container orchestration – not too simple, not too complex, but just right for many situations.

Next time you're starting a new project, consider whether Swarm might be a better fit than jumping straight to Kubernetes.

You might be surprised at how much easier it makes your life.


Thank you for reading.
Feel free to reply directly with any question or feedback.
Have a great weekend!

ESPRESSO FRIDAYS

Every once in a while I send hand picked things I've learned. Kind of like your filter to the tech internet. No spam, I promise!

Read more from ESPRESSO FRIDAYS

You’ve been parsing JSON wrong your whole life This issue is brought to you by: Secure Your AI Future at DevSecCon 2025 Software development is undergoing a seismic shift as AI transforms how we build, deploy, and secure applications. Register for the 1st-ever Global Community Summit on AI Security, covering critical strategies to empower AI innovation without compromising security. Register for DevSecCon 2025 (It’s Free!) Ever opened a massive “.log” file and realized it’s just one long,...

Wait… cURL can do WHAT?! Brought to you in collaboration with 1Password and Browserbase: 🔐 Your AI Agents Can Finally Log In! 1Password and Browserbase just partnered to solve AI’s biggest security nightmare: authentication without exposing credentials. Introducing 1Password’s Secure Agentic Autofill, allowing you to connect your 1Password Enterprise Password Manager to your browser automation agent powered by Browserbase. Build AI agents that can actually work without compromising security....

Postgres is not a database. For years, we’ve been taught to see Postgres as the reliable, open source workhorse for storing our data. Everyone called it "The Toyota of databases", you know... it just works. But to leave it at that is to miss the whole story.Postgres isn’t just a place to put your data, it’s a powerful development platform that can become the core of your entire backend, an operating system (yea, bold) for your application’s stack. Diving deep into its capabilities I learned...