Kubernetes and Docker: What’s the difference?

Docker helps you create and run containers. Kubernetes manages them while you sleep.

In this age of containers, hundreds of tools are vying for your time and attention, and they don’t come much bigger and louder than Docker and Kubernetes. But what does Kubernetes do, which Docker does not? And what’s the real relationship between these two container-loving pals? Let’s find out.

Today we’re going to answer a common question amongst developers, DevOps newbies, IT architects – and in fact thousands of people – who all ask:

“What’s the difference between Docker and Kubernetes?”

To answer this question, we’ll need to understand what each of these DevOps tools do, and when you might use them.

But first! If you want the quick summary, then here are the key facts you should know:


  • Docker and Kubernetes aren’t “either/or” competitors – they’re two technologies which complement each other.

  • Docker is a company which provides a set of tools for building and sharing container images, and running containers at both small and large scale.

  • Kubernetes is a tool which manages (“orchestrates”) container-based applications running on a cluster of servers.

  • You can use Docker without Kubernetes… and you can use Kubernetes without Docker.

What is Docker?

Docker is a few things, which muddles the water a little! It’s a company, it’s a set of tools, and it’s also a command. So what exactly is Docker?

Docker is a company that makes a set of open source tools to make it easier to package and run applications in containers.

So the next question is – what is a container?

What is a container?

A container is a way to run an application, which surrounds it, and its dependencies, with a virtual “wall”, which isolates it from other applications on the computer.

Dirk Merkel1 puts it pretty eloquently:

Docker promises the ability to package applications and their dependencies into lightweight containers that move easily between different distros, start up quickly and are isolated from each other.

  • Isolated… meaning it won’t interfere with other programs running on your computer, and

  • Consistent… meaning that every time you run a Docker container, it should run the same way.

  • Portable… meaning that a container can be stopped, moved to anoher

With Docker’s tools, you can create and share container images, run containers on your laptop or server, and even manage containers running on multiple servers, with Docker’s Swarm mode.

Let’s look a bit more about the features of Docker.

Docker’s features and tools

In Linux, the technology already existed to create containers and containerised apps. But it was a little esoteric and hard to understand.

Docker made it much easier for developers to understand and use container technology, by creating some useful features, like:

Some of the features of Docker include:

  • Docker Engine – a command line tool (docker) which creates and runs containers on your computer

  • The Docker container image format – for creating and sharing container images, which later became an open standard

  • The Dockerfile – a language for building container images

  • Docker Hub – an online registry for publishing and sharing container images over the internet

  • Docker Compose – a lightweight way to share container setup instructions

  • Docker Swarm mode – a tool for managing containers running on multiple servers

Getting started with Docker

The easiest way to start using Docker is to install Docker Desktop, which bundles all of these tools into a program for Windows or Mac. Or, if you’re a little more familiar with the command-line, you can install Docker Engine directly into a virtual machine.

So, once you’ve installed Docker Desktop, what might you use Docker for?

What can you do with Docker?

There are lots of things that you can do with Docker:

  • Create container images (also called Docker images) for your applications - with docker build and a Dockerfile
Using Docker to create and publish container images

Using Docker to create and publish container images

Source: Tutorial Works

  • Run your own container images using Docker Engine

  • Share images with coworkers or other teams, by pushing them to a private image registry

  • Share images on the internet by pushing them to Docker Hub (a public image registry)

  • Run third-party containers such as databases, using images pulled from Docker Hub

  • Run multi-container applications with Docker Compose

Along with these useful developer features, there’s also Docker Swarm mode, which is a utility for managing a cluster of Docker instances. Swarm lets you manage containers running on many different servers.

Now we’ve seen what Docker is, let’s take a look at Kubernetes.

What is Kubernetes?

If docker run is the way to run containers on your laptop, then Kubernetes is like a robot that runs docker run on dozens, or hundreds, of servers.

Kubernetes turns a set of servers into a complete, private cloud.

Kubernetes is server-side software for managing containers.

It automates all of the time-consuming tasks like creating containers and placing them on servers, configuring containers, checking container health, and managing access to resources like memory and CPU. This puts it in a category of software called container orchestration tools.

Kubernetes does similar things to Docker Swarm, but there are a few differences, which you’ll see in the comparison table further below.

Kubernetes hides away the details of your servers, and instead provides you with a standard API to deploy software onto the cluster. As a developer or sysadmin, you don’t deploy your container-based app to a specific ‘server’, you give Kubernetes some instructions, and it decides where to pull the container image and start the container.

What are the alternatives to Kubernetes?

Docker Swarm mode, Hashicorp Nomad, Apache Mesos and AWS’s Elastic Container Service are all container orchestration tools and are alternatives to Kubernetes.

Kubernetes features and tools

Kubernetes provides a set of “primitives”. These primitives are like building blocks for creating apps, in the same way as you might build a model from standard Lego bricks. These are the terms you might have heard of, like Pods, Services and Deployments.

Kubernetes comes with these features:

  • Container scheduling – intelligently figuring out where to place containers, based on how busy each server is.

  • Container management – starting, stopping and restarting containers.

  • Auto-scaling containers – starting more containers when needed. For example: if an app is suddenly experiencing high traffic (e.g. on Black Friday), Kubernetes can start more containers to handle the load. It can also stop those containers afterwards, so you’re not using resources which you don’t need.

  • Networking – Creating and managing networks to allow containers to communicate with each other, and to load balance traffic across several instances of your app. (You could do this yourself, but when you’re running 1,000s of containers it gets real tough)

  • Storage – managing access to disk, for containers which need to write files

  • Logs and monitoring – making it easier to gather logs from containers and monitor containers’ health

  • Security – establishing common rules and enforcing security restrictions on containers

Plus, Kubernetes is very extensible. You can change the way the networking layer works… you can connect your Kubernetes cluster to your cloud account so it can request more resources if needed… you can even use Kubernetes to manage virtual machines as well as containers (using the KubeVirt project).

If you want to know a little more about Kubernetes, try Linux Foundation’s Introduction to Kubernetes course (it’s free).

Things you can do with Kubernetes

Once you’ve got a Kubernetes cluster up and running, what do you actually do with it? Why do people use Kubernetes?

  • Deploy your own container-based applications

  • Deploy third-party container-based applications, like databases or web applications

  • Connect your apps to each other – e.g. so that your back-end API can talk to the database, or connect many containers together into an architecture of microservices

  • Upgrade applications by stopping existing containers and starting new ones with the updated software

  • Gather metrics on your apps – e.g. memory usage, CPU usage, and so on.

Kubernetes is popular because it standardised all of this stuff. We’ve been doing things like networking and log management for a long time, but now there is a standard way to implement these requirements (which pretty much every company has).

Comparing Docker and Kubernetes

Now that we’ve seen what Docker and Kubernetes are all about, what are the differences between them?

To be truthful, we can’t compare Docker and Kubernetes directly. There are many different tools under the “Docker” name, and Kubernetes is a single project. But if you’re still unsure of the difference, we can probably say:

  • Docker is a set of tools for building and running containers, on your laptop, or on a bunch of servers.

  • Docker Swarm is Docker’s tool for managing containers on a cluster of servers.

  • Kubernetes is a tool for deploying and managing containers on your servers, or in the cloud.

Differences between Docker Swarm and Kubernetes

Here’s a table which compares the different features and of Docker Compose, Docker Swarm and Kubernetes:

Docker Compose Docker Swarm mode Kubernetes
Manages a group of containers on a single host Manages a cluster of instances of Docker Engine Manages a cluster of hosts running any compatible container runtime
Comes with Docker Desktop Built into Docker Engine Standalone project, not connected with Docker (but can be installed with Docker Desktop)
Works with Docker Engine Works with Docker Engine Works with any compatible container runtime
Control with docker-compose Control with docker swarm Control with kubectl
.. .. Cloud integration with providers like AWS
No auto-scaling No auto-scaling Containers can be automatically scaled if they need more resources
Product from Docker Inc. Product from Docker Inc. Many distributions available, like vanilla Kubernetes, OpenShift, VMware Tanzu, k3s, microk8s

Frequently Asked Questions

Which should you learn first, Docker or Kubernetes?

If you’re planning to work with Kubernetes, you should probably get comfortable using Docker first. Using Docker will teach you the fundamentals of containers, like how to create an image, and how to run containers, and add storage and environment variables.

Then you will find it easier to connect Kubernetes concepts like Pods and PersistentVolumes to your existing container knowledge.

Which should you adopt, Docker or Kubernetes?

Both, seriously! You can use Docker for building your container images on your laptop, and then run your containers on a Kubernetes cluster.

Or, if you prefer, you can use Docker Swarm to orchestrate your containers instead of Kubernetes.

Wrapping it up

In this article we’ve seen that Docker and Kubernetes are two big tools for creating and running containers.

Dive into Docker on your laptop if you want to learn how to build and run containers. Then move onto Kubernetes to orchestrate your containers, and run them in production!

Want to learn more? The Containers Fundamentals course will teach you how to install, spin up, manage and troubleshoot containers.

Tom Donohue

By Tom Donohue, Editor | Twitter | LinkedIn

Tom is the founder of Tutorial Works. He’s an engineer and open source advocate. He uses the blog as a vehicle for sharing tutorials, writing about technology and talking about himself in the third person. His very first computer was an Acorn Electron.

Join the discussion

Got some thoughts on what you've just read? Want to know what other people think? Or is there anything technically wrong with the article? (We'd love to know so that we can correct it!) Join the conversation and leave a comment.

Comments are moderated.