Does K8s have to know Docker first?

The relationship between K8s and Docker

Docker and K8s often appear together, and the logos of the two seem to have a certain connection. One is a whale with a container on its back, and the other is the helm of a ship.

However, the two cannot be discussed in one dimension. Docker is a popular Linux container solution. It uses Namespaces, Cgroups and UnionFS to achieve mutual isolation between container processes on the same host.

NameSpaces: Isolate the process, so that the process can only access the mount directory, PID, NetWork and other resources in this namespace
Cgroups: Limit the upper limit of various resources of the computer system that the process can use, including CPU, memory, disk, network bandwidth, etc.
Union file system UnionFS: saves all files and directories of an operating system, and adds files that the application depends on for running on it. When creating a container process, specify Mount Namespace for the process to mount the image file into the container, and use chroot to switch the root directory of the process to the mounted directory, so that each container process has an independent operating system directory.

K8s is a cluster management solution with container orchestration capabilities. It can schedule each running application component Docker container according to the definition of the application. However, Docker is not the only choice for K8s containers. The K8s container runtime supports docking with a variety of containers, such as CoreOS's Rkt container (formerly known as Rocket, now renamed Rkt), Apache's open source Mesos container, etc. As long as the container implements the interface conventions of the K8s container runtime, K8s can be scheduled.

Docker has also launched its own container cluster management solution, Docker Swarm, which is a competitor with K8s, but almost no one uses it in production.
The in-depth reasons why Docker Swarm is not popular will not be discussed in depth. From the reports of some IT media, the possible reasons are

Deeply bound to Docker, people are naturally very disgusted with totalitarianism.

Docker is inexperienced in large-scale cluster management, and can't give a good solution like Google.

Docker for containers, how much do you need to learn

After reading the relationship between K8s and Docker, we already have the answer. If you want to learn K8s, you don't have to know Docker. But after all, Docker is still the most popular Linux container solution at present. In most cases, we still choose to use Docker. So to what extent does Docker make it easier for us to learn K8s?
This mainly depends on what we want to learn about K8s. Even if the container running on K8s chooses Docker, if we are building some infrastructure software, such as MySQL, Redis, etc., because these organizations have provided images of software containers, I would The experience of using it is that the various commands of those Docker are completely unnecessary.
For example, to run a MySQL application on the K8s cluster, write the application manifest file (that is, various configurations and expected states), and then run it directly
kubectl apply -f mysql.yaml is fine. When the K8s container is running, it will help us adjust the Docker interface to download the image and run the container according to the image name in the manifest file.
apiVersion: apps/v1
kind: Deployment
name: mysql
app: mysql
type: Recreate
app: mysql
- image: mysql:5.7
name: mysql
value: superpass
- containerPort: 3306
name: mysql
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
- name: mysql-config
mountPath: /etc/mysql/conf.d/my.cnf
subPath: my.cnf

The above configuration file has been deleted. For a complete working case, please refer to:

Using Kubernetes to build a portable development environment with MySQL and Redis

However, in addition to building this kind of basic software, we use K8s to learn K8s to make the services we develop more robust and portable by relying on the K8s cluster management and scheduling capabilities. At this time, the Docker skills master the basic commands for Dockerfile writing, packaging and uploading images. A few simple knowledge in this part, I feel that I can master it in two hours. Here I recommend my previous articles.

How to package a Go application into a Docker image
How to package a Java application into a Docker image

It is enough to learn these simple Docker knowledge, which can support us to learn and practice K8s, and other Docker-related knowledge can be learned in the process of encountering problems and solving problems during K8s practice.
This article gives you an answer to the relationship between Docker and K8s. I hope that I am still hesitant about whether I can learn K8s directly with my existing knowledge base. Hurry up and act quickly. K8s is a typical entry. .

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us