First of all, it should be clear that Kubernetes has not completely abandoned Docker, but has changed the way Docker is used.

This change is mainly due to the announcement that Docker will be deprecated as a container runtime starting from version 1.20 of Kubernetes (removal of Dockershim). This means that although container images built with Docker can be run in a Kubernetes cluster, Kubernetes will no longer use Docker as the container runtime.

1. What is Docker:

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable container and then publish it to any popular Linux machine, which can also be virtualized. Containers completely use the sandbox mechanism and do not have any interfaces with each other (similar to iPhone apps). More importantly, the container performance overhead is extremely low.

Docker uses a client-server (C/S) architecture model and uses remote APIs to manage and create Docker containers. Docker containers are created from Docker images. Images can be thought of as “templates” for containers, and containers are instantiated objects of these templates. Docker provides a very convenient way to use images. In addition to using local images, you can also download tens of thousands of images from Docker Hub.

2. What is Kubernetes:

Kubernetes (also known as K8s) is an open source system for automating the deployment, scaling, and management of containerized applications. It was designed by Google and donated to the Cloud Native Computing Foundation for maintenance. Kubernetes provides a framework for deploying applications, supports application scaling and fault handling, and provides a series of tools and services to meet various needs.

Kubernetes core capabilities include:

  • Automate container deployment and replication
  • Scale up or down the number of containers at any time
  • Organize containers into groups and provide load balancing among containers
  • Service discovery and load balancing
  • Automatically mount storage system
  • Automated rolling updates
  • Self-healing, such as restarting failed containers

3. The difference between Docker and Kubernetes:

Although Docker and Kubernetes are both tools related to containerization technology, they are significantly different in some aspects.

Scope and purpose of use : Docker mainly focuses on packaging and running containers, simplifying the delivery of applications. Kubernetes focuses more on the coordination and management of containers, including automatic deployment, expansion, running and scheduling of containers.

Design and Architecture : Docker uses a simple design that is easy to understand and use. It can run on a single machine, or can be combined with Docker Swarm to work together on multiple machines. Kubernetes is more complex, offers more features and greater flexibility, and is designed for running and managing containerized applications on a cluster at scale.

Functionality and Features : Docker handles the creation and running of containers directly, while Kubernetes provides a more sophisticated scheduler and cluster management tools. Kubernetes can manage and schedule applications composed of multiple containers, and has advanced features such as automatic expansion and self-healing.

ecosystems and communities : While both Docker and Kubernetes have strong community support, Kubernetes has a richer ecosystem in the field of cloud computing and microservices, supporting more cloud platforms and product integrations.

In general, Docker focuses more on the life cycle of a single container, while Kubernetes focuses more on the overall management of the container cluster. Under the trend of microservices and cloud-native applications, the two are often complementary. Docker is used for containerized applications, and Kubernetes is used to manage these containerized applications.

Changes in how Kubernetes uses Docker:

First of all, it should be clear that Kubernetes has not completely abandoned Docker, but has changed the way Docker is used. This change is mainly due to the announcement that Docker will be deprecated as a container runtime starting from version 1.20 of Kubernetes (removal of Dockershim). This means that although container images built with Docker can be run in a Kubernetes cluster, Kubernetes will no longer use Docker as the container runtime.

The reason behind this change is the technical differences between Docker and Kubernetes. Docker is a large-scale application that includes many functions, including image management, storage, networking, etc. in addition to the container runtime. Kubernetes actually only needs the container runtime function. Therefore, in order to reduce the burden on Kubernetes and manage containers more efficiently, Kubernetes began to support a more lightweight and standardized container runtime interface (CRI).

Kuberetes has not eliminated Docker:

This does not mean that Docker is obsolete, because container images built with Docker can still run in Kubernetes. It’s just that Kubernetes uses other container runtimes (such as containerd or  CRI-O ) to run these images directly. The Docker image itself complies with the OCI (Open Container Initiative) standard and can therefore be used by any standard container runtime.

Docker’s role in the Kubernetes ecosystem:

In this case, Docker is more of a development tool than a container runtime in a production environment. Developers can still use Docker to build, test container images, and then deploy these images to Kubernetes clusters. In fact, this change makes Kubernetes more efficient because it can interact directly with the underlying container runtime interface, reducing unnecessary middle layers.

Two code examples to show how to use containers in a Kubernetes environment. The first example is a Dockerfile used to create a simple Docker image; the second example is a Kubernetes deployment configuration file (Deployment) used to deploy this image in a Kubernetes cluster. These two examples will show how to deploy a Docker containerized application into a Kubernetes cluster.

Example 1: Dockerfile

This Dockerfile example will create a Docker image of a simple Node.js application.

# 
FROM node:14

#  /app
WORKDIR /app

# 
COPY package*.json ./

# 
RUN npm install

# 
COPY . .

# 
EXPOSE 8080

# 
CMD ["node", "server.js"]

In this Dockerfile, we create a new image based on the official Node.js image, install the application dependencies, and set the command to be executed when the container starts.

Example 2: Kubernetes Deployment configuration file

This example YAML file defines a Kubernetes Deployment for deploying the Docker image created above.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs-app
  labels:
    app: nodejs-app
spec:
  replicas: 2  # 
  selector:
    matchLabels:
      app: nodejs-app
  template:
    metadata:
      labels:
        app: nodejs-app
    spec:
      containers:
      - name: nodejs-container
        image: your-dockerhub-username/nodejs-app:latest  # 
        ports:
        - containerPort: 8080  # 

In this YAML file, we define a Deployment named nodejs-app. It will deploy two copies of the container, each running the your-dockerhub-username/nodejs-app:latest image (you need to replace this with your own Docker Hub username and image name). This deployment configuration specifies that the application listening port inside the container is 8080.

Combining these two examples, you can see how Docker and Kubernetes work together to containerize and deploy an application. First, use Docker to build an application image, and then deploy the image in the cluster through Kubernetes deployment configuration.

In summary, has Docker really been abandoned by Kubernetes?

Therefore, we can say that Kubernetes has changed the way it uses Docker, rather than completely abandoning Docker. This change more reflects the trend of Kubernetes’ development toward standardization and efficiency, while also retaining Docker’s core value and widespread use in the field of container technology. For developers, this means they can still use Docker in the development process, while Kubernetes is more focused on orchestration and management of containers.

Leave a Reply

Your email address will not be published. Required fields are marked *