Skip to content
Technology transformation expertise firm · ARDIANE Group Innovate, secure, succeed

Cloud and platforms

Docker vs Kubernetes: building containers, orchestrating them, or both

In brief

Docker is used to build container images and run them on a machine, Kubernetes to orchestrate containers across a set of machines: the Docker vs Kubernetes comparison concerns two complementary levels. Management Square compares their roles here and describes the situations where one is enough without the other.

Page contents

“Do we stay on Docker or move to Kubernetes?” The question comes from a team whose containers run on a few servers, and who see new services, an availability requirement or a change of hosting provider on the horizon. Put this way, the Docker vs Kubernetes debate weighs up two tools that do not do the same job.

Docker is used to build container images and run containers on a machine. Kubernetes keeps containers in service across a set of machines: it places them, restarts them, scales them and exposes them to the network. The first builds and runs, the second orchestrates. The two can therefore be used together, Docker on the development workstation and in the build pipeline, Kubernetes in production. The real decision concerns orchestration: do you need it, and who will operate the cluster that provides it?

Docker vs Kubernetes: two layers of the same stack

Docker presents itself in its documentation as an open platform for developing, shipping and running applications. Its core, Docker Engine, works on a client-server model. A daemon (dockerd) receives commands from the client and takes care of building images, exchanging them with a registry and launching containers. An image is described in a Dockerfile. To manage the container life cycle, Docker Engine itself relies on containerd, which uses runc by default.

Kubernetes defines itself as an open source platform for managing containerised workloads and services, which facilitates declarative configuration and automation: you describe the desired state, and the system works to reach it. A cluster brings together a control plane and nodes. On each node, an agent, the kubelet, makes sure that pods are running. It does not launch containers itself. It addresses a container runtime through an interface defined by the project, the Container Runtime Interface (CRI). The documentation cites containerd and CRI-O among common runtimes.

A few frequent misunderstandings remain to be cleared up. Kubernetes does not build images: its documentation states that it does not deploy source code and does not build the application. Nor does it need Docker on its nodes. Versions prior to 1.24 included a direct integration with Docker Engine, the dockershim component, removed from the project from that version onwards. Docker Engine remains usable as a runtime by means of the cri-dockerd adapter.

Images, for their part, are not affected by this removal. Those produced by the docker build command work with all CRI implementations, because the image format is standardised by the Open Container Initiative (OCI). The image is the junction point between the two tools.

Comparison table of Docker and Kubernetes

Docker (Docker Engine, excluding Swarm mode) Kubernetes
Role Build images, run containers Orchestrate containers that have already been built
Scope One machine A cluster: control plane and nodes
Object handled The image and the container The pod, the smallest deployable unit, which groups one or more containers
Building images Yes, from a Dockerfile No
Failed container Restart on the same machine, according to a policy set at launch Restart, or replacement on another node if the machine is lost
Scaling Manual Horizontal, on command or automatic
Updating an application To be scripted Built-in rolling deployment and rollback
Network exposure Publishing ports on the machine Service discovery and load balancing
What has to be operated One daemon per machine A control plane, nodes, a network, version upgrades

Docker is not limited to this single-machine operation. Docker Compose defines and launches, from a YAML file, an application made up of several containers. Swarm mode, built into Docker Engine, manages a cluster of Docker machines according to a declarative service model: desired number of replicas, replacement of lost replicas, load balancing.

Docker therefore has its own orchestrator. When the question really concerns orchestration, the exact comparison sets Swarm against Kubernetes. Swarm is activated in Docker Engine and driven with the same command line, with no additional software. Kubernetes requires more learning and more operations. Its documentation describes in particular automatic scaling and extension mechanisms, whereas the Swarm mode documentation describes scaling by declaring the desired number of replicas. Kubernetes is also offered as a managed service by many cloud providers.

Docker alone: the cases where an orchestrator is too much

Docker meets the need, without Kubernetes, in several common situations:

  • the development workstation and the integration pipeline, where the aim is to build an image and try it out;
  • an application hosted on one or a few servers, launched with Compose, for which a brief interruption remains acceptable;
  • internal tools, scheduled jobs, demonstration environments;
  • cloud providers’ managed container execution services, which take an image and run it without exposing a cluster to administer.

This choice has limits that are best known in advance. The loss of a machine interrupts what it hosted. Scaling and updates rely on scripts that the team writes and maintains. As long as the business can live with this, adding an orchestrator mainly creates an operational burden.

When Kubernetes is justified, with or without Docker

Orchestration is justified when several conditions combine: many services, deployed often and by several teams; availability that must survive the loss of a machine; a variable load, which calls for automatic scaling; the need for an identical foundation from one hosting provider to another.

A Kubernetes cluster can run without Docker being installed on any of its nodes, since they use a runtime such as containerd or CRI-O. The images themselves can be built by other tools, and the Kubernetes project cites several of them. Docker nevertheless remains in common use upstream, on workstations and in build pipelines. Docker Desktop also embeds a local Kubernetes server, intended for development and testing.

The price of Kubernetes is operating it. Cluster version upgrades, networking, access management, security rules, resources requested by each container: these subjects call for people dedicated to them. A managed service lightens this burden without removing it. Monitoring the cluster is a workstream in its own right, detailed in our article on Kubernetes monitoring.

Before adopting an orchestrator: the application and the team

Kubernetes does not improve an application that has not been prepared for it. It restarts, moves and multiplies containers, and the application must be able to cope. This requires clean start-up and shutdown, configuration supplied from outside, logs written to standard output, a health check that the orchestrator can query, and no state kept in the container. Stateful components, databases first and foremost, require a separate study.

The second check concerns the organisation. If every team has to learn Kubernetes in order to ship, the gain from orchestration is lost in configuration. One answer is to entrust the cluster to a platform team, which provides the others with ready-to-use deployment paths. This is the principle of platform engineering, and the subject of our DevOps and platform engineering offering.

Docker and Compose do the job as long as the containers fit on a few machines and an interruption can be recovered from. The subject reopens on the day the loss of a server becomes an incident for the business, or when the number of services exceeds what a team can deploy by hand. It is then orchestration that needs to be examined, operating cost included.

FAQ

Frequently asked questions

Another question? Ask us

What is the difference between Docker and Kubernetes?

Docker builds container images and runs containers on a machine. Kubernetes orchestrates containers across a set of machines: it places them, restarts them in the event of failure, scales them and exposes them to the network. The two operate at different levels and are often used together, Docker upstream to build the images, Kubernetes in production to run them.

Does Kubernetes still use Docker?

Kubernetes relies on a container runtime that complies with its CRI interface, for example containerd or CRI-O. According to its documentation, versions prior to 1.24 integrated Docker Engine directly through a component called dockershim, since removed. Docker Engine remains usable by means of the cri-dockerd adapter. Images built with Docker continue to work on all these runtimes.

Can Docker be used without Kubernetes?

Yes. Docker is enough on a development workstation, in an integration pipeline and for an application hosted on one or a few servers, launched for example with Docker Compose. The limits are well known: the loss of a machine interrupts what it hosted, and scaling and updates rely on scripts. Kubernetes comes into the discussion when these limits become a problem for the business.

Docker Swarm or Kubernetes: which should you choose?

Both are orchestrators. Swarm mode is built into Docker Engine and is driven with the same command line, with no additional software. Kubernetes covers a broader functional scope, requires more learning and is offered as a managed service by many cloud providers. The choice depends on the number of services, the skills available and the need to find the same foundation from one hosting provider to another.

A project to bring to completion?

A first conversation is enough to understand your challenge, identify the right people and tell you frankly what we can bring.