DEV Community

Pavan Belagatti
Pavan Belagatti

Posted on

Kubernetes or Docker Swarm?

Docker adoption is still growing exponentially and more and more companies have started using it in Production.
It is important to use an orchestration platform to scale and manage your containers. Imagine a situation where you have been using Docker for a little while, and have deployed on a few different servers. Your application starts getting massive traffic, and you need to scale up fast, how will you go from 3 servers to 40 servers that you may require? And how will you decide which container should go where? How would you monitor all these containers and make sure they are restarted if they exit?

This is where Kubernetes comes in.

You might just ask, Can just as easily achieve the same result with Docker Swarm, with far less complexity too.

It’s not that easy to compare Kubernetes and Docker Swarm. Why?

Docker Swarm is preferred in environments where simplicity and fast development is preferred. Whereas Kubernetes is fit for the environments where medium to large clusters are running complex applications.

Unquestionably, Kubernetes gets a lot of attention given that it has a huge community out there(The Kubernetes project on GitHub has over 1500 contributors and they actively release tons of tooling, extensions, etc.) and it easily rationalizes applications, particularly web-centric applications. But it may not always be the best choice for a given context and hence Kubernetes vs Swarm is not always the question to be asked, rather the kind of questions that need to be asked when considering container orchestration need to think the types of applications that need to run.
Along with all this, you also need to consider the facts and ease with

Installation and set-up

Logging and monitoring

Scalability

Availability

Networking

For example, when it comes to installation and setup, Kubernetes can be quite complex with steep learning curve whereas Docker Swarm is easy to install with a fast setup.

What do you prefer, Kubernetes or Docker Swarm?

Top comments (3)

Collapse
 
jillesvangurp profile image
Jilles van Gurp

Kubernetes is indeed a beast to set up whereas you can automate docker swarm cluster creation with some straight forward ansible scripts (or whatever you prefer). There's not much to it: install docker, configure keys, fire it up. Done. Of course doing it properly involves a lot more.

This is the point with Kubernetes: you don't reinvent the wheel of automating its deployment. Instead you use either hosted Kubernetes or something like kops to automate cluster creation and management. That nicely hides the complexity of setting it up properly. And of course setting it properly is not really optional. You want it to be secure. You want it to be resilient, etc. This requires mitigating all sorts of problems. You can try to do that yourself but it is better to reuse what others have done here and benefit from improvements that happen over time for issues you probably never even realized you had.

Docker swarm is nice in it's elegance but Docker (the company now officially backs both swarm and kubernetes. This has been widely interpreted as Kubernetes having "won". In practical terms we can expect Docker spending less energy on swarm or promoting that as a preferred solution and I would not be surprised to see it eventually disappear. So, sadly Swarm seems like it is a dead end. I would not waste time on it.

Collapse
 
pavanbelagatti profile image
Pavan Belagatti

That's a great explanation. Ya, even when I asked the same thing on my other social networks, many people prefer Kubernetes over Docker Swarm. So yes, I see Kubernetes winning here.

Collapse
 
marsavela profile image
Sergiu Marsavela

IMHO Docker Swarm is dead, mainly because the whole industry is moving with Kubernetes. Is true that Kubernetes is more complex and the learning curve is steeper, but if you want to have anything serious, you won't consider any other orchestration engine right now.