DevOps

Docker vs Kubernetes: The most important differences

In this article, we will introduce you to Docker vs Kubernetes and their most important differences.

1. Introduction

Docker and Kubernetes are two open-source tools that work together to ensure that an application works anywhere and runs at the desired state all the time. The following diagram outlines developing, packaging, and deploying steps utilizing Docker and Kubernetes.

Docker vs Kubernetes - Application Pipeline
Figure 1 Application Pipeline

The most important difference between Docker and Kubernetes is the problem they solve:

  • Docker containerizes an application so it runs anywhere.
  • Kubernetes ensures an application runs at the desired state all the time by providing orchestration tools to monitor, auto-recover, and load balance containers.

2. Docker

Docker is an open platform for developing, shipping, and running applications in a container. It provides an open standard for packaging and distributing containerized applications. The initial version was released on March 20, 2013.

As Figure 1 outlined, a developer develops an application at a local machine. Then a deployment artifact is shipped to a server. Lastly, an application is started after dependencies are installed and configured.

The application may fail if there is any difference between the developer’s local machine and server machine. In that case, it’s very hard to troubleshoot as developers cannot reproduce the problem locally. Docker is created to solve this problem by packaging everything as an image file and deploying the packed image in a container. Therefore, applications work anywhere.

2.1 Architecture

Docker is based on client-server architecture. There are three major components:

  • Docker Daemon – creates and manages Docker images, containers, networks, etc.
  • Rest API – instructs Docker Daemon what to do.
  • CLI commands – command-line interface to enter the docker commands.

2.2 Docker Registry

Docker provides DockerHub as a public docker registry to host docker images. You can find lots of useful base images: such as Ubuntu for Linux, windows for Windows, etc. You can push your own images too.

2.3 Dockerfile

A Dockerfile is a text file that contains all the commands that a user could call on the command line to assemble an image. It is a receipt to deploy a container. Application developer packages an application as a docker image by executing docker build command with a specified Dockerfile.

Click this example for steps to build, pull, and push a docker image for a “hello world” Spring boot web application.

Note:

  • Image – is a file that defines how to construct a Docker container to run the desired application. It likes a Class in Java.
  • Container – is built from a docker image as a lightweight and standalone software container. It’s similar to an Object instance in Java

3. Kubernetes

Kubernetes is a container orchestration tool that enables containerized application runs at the desired state all the time. Its initial release date was June 7, 2014.

As figure 1 outlined, system administrators can use Kubernetes CLI commands to scale, network, secure, and maintain containerized applications effectively.

3.1 Architecture

There are four major components:

  • API Server – accepts requests and then manages pods, services, replicationcontrollers.
  • Kubelet – installs at each worker node and communicates with the master node to ensure the containers are running in a POD.
  • Container run-time – Docker is the most popular container run-time. Click here for other container run time.
  • CLI commands – Kubeclt CLI manages the Kubernetes cluster. It provides CLI commands to deploy, scale, secure, etc containers.

An application developer and system administrator use the same set of kubectl commands to manage containers. Click this article for the most commonly used kubectl commands.

3.2 Kubernetes Objects

Here are three Kubernetes objects which ensure an application runs at the desired state and can be accessed outside the container.

  • POD – is a group of one or more containers.
  • Deployment – declares the desired state of the application.
  • Service – exposes an application running on a set of Pods as a network service.

4. Application Pipeline

As you have seen in Figure 1, the docker image at the developer’s local machine is the same as the one deployed in Kubernetes worker nodes. When the application is managed by Kubernetes, It’s very easy to scale up and down containers via kubectl commands as it communicates with the Kubernetes API server to manage PODs running at the worker nodes.

5. Summary

In this article, I outlined Docker vs Kubernetes based on architecture and CLI commands. They solve different problems. They can work together to create an application pipeline which includes steps to develop, package, deploy, and monitor an application. They can work with other tools too. Docker provides a Docker swarm to scale containers.

Kubernetes supports another container runtime besides Docker. But more and more companies adapt to combine them together to develop, package, deploy, and monitor their application.

Last updated on Feb. 27th, 2022

Mary Zheng

Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button