As K8S becomes more popular as a container choreography solution, some people are comparing Docker to K8S and asking: Doesn’t Docker smell good?
K8s is short for Kubernetes, and the ‘8’ stands for the middle eight characters.
In fact, Docker and K8S are not direct competitors, they are interdependent. Docker is a container platform, and K8S is the coordinator of container platforms such as Docker.
1. Age of containerization
Virtualization technology has gone through three eras, and without the evolution of containerization technology, Docker technology would not have been born.
(1) Physical machine era: Multiple applications may run on a single machine.
(2) Virtual machine era: a physical machine installs multiple virtual machines (VMS), and a VIRTUAL machine runs multiple programs.
(3) Containerization era: one physical machine installs multiple containers, and one container runs multiple programs.
Containerization solves one of the most frustrating problems in software development, described in a dialog:
Tester: You have a problem with this function.
Developer: MY local is good!
Developers who write code and deploy it to a test or production environment after testing in their own local environment often encounter a variety of problems. Obviously, there are many reasons why the code that runs perfectly locally has many bugs after deployment: different operating systems, different dependent libraries, etc. In a word, it is because the local environment and remote environment are inconsistent.
Containerization addresses this key problem by separating the software program from the underlying environment in which it is run. After coding, the developer packages the program into a container image, which lists the dependent environment in detail. Running the standardized image in different containers fundamentally solves the problem of inconsistent environment.
⭐ While the container concept has been around for a long time, the open source project Docker, launched in 2013, largely helped popularize the container technology and helped push the containerization and microservices trend in software development, which has come to be known as cloud native development.
2. The knife weapon of containerization
- Portability: do not depend on the specific operating system or cloud platform, such as ali Cloud or Tencent cloud directly at will migration.
- Small footprint: A container only needs a dependency list of its application and all the containers and libraries it needs to run, not all of the dependency libraries packaged together.
- Sharing bin and lib: Different containers can share bin and lib, further saving space.
3. Docker comes out of nowhere
In 2010, a young man founded a company named dotCloud in San Francisco, the United States, and developed the core technology of Docker, thus opening the era of container technology.
Later, dotCloud simplified and standardized its container technology and named it Docker, which is the familiar whale logo.
In 2013, dotCloud announced that Docker would be open source. As more and more engineers discovered its advantages, Docker’s popularity rose rapidly and became one of the hottest open source technologies at that time.
More than 30% of enterprises currently use Docker in their AWS environments, and this number continues to grow.
At this time, Docker has become the most popular open source technology in the industry. Even giants like Google, Microsoft, Amazon and VMware have expressed their full support for it.
After Docker became so popular, dotCloud simply changed its name to Docker Inc.
Why Docker and container technology are so popular? To put it bluntly, because it is “light”.
Before container technology, the industry’s influencers were virtual machines. Virtual machine technology is represented by VMWare and OpenStack.
I believe many of you have used virtual machines. Virtual machine, is in your operating system inside, install a software, and then through this software, simulate a or even more “sub computer” out.
In the “sub computer”, you can run programs like a normal computer, such as logging in to QQ. If you wish, you can make several “sub-computers”, which are all logged into QQ. Between “child computer” and “child computer”, is mutually isolated, do not affect each other.
VMS are virtualization technologies. Container technology like Docker is also a virtualization technology, belonging to lightweight virtualization.
Virtual machines can isolate many “child computers,” but they take up more space, start up slower, and can cost money for virtual machine software (for example, VMWare).
Container technology has none of these disadvantages. It doesn’t need to virtualize the entire operating system, just a small scale environment (sort of “sandbox”). Docker, which makes it easy to create containers and container-based applications, was originally built for Linux and now runs on Windows and MacOS.
It starts up quickly and can be done in seconds. Moreover, it is highly resource efficient (thousands of Docker containers can run simultaneously on a single host). In addition, it takes up a small amount of space. Virtual machines typically require several to tens of gigabytes of space, while containers require only megabytes or even kilobytes.
Because of this, container technology is warmly welcomed and pursued, and develops rapidly. Docker itself is not a container. It is a tool for creating containers. It is an application container engine. To understand Docker, look no further than its two taglines.
The first sentence is “Build, Ship and Run”.
The second slogan is “Build once, Run anywhere.”
- Build: An image is like a container that contains resources such as files and runtime environments.
- Ship (transport mirror) : Transport between the host and the warehouse, which is like a superterminal;
- Run (Run image) : A running image is a container, and the container is the place to Run the program.
⭐ To be clear, this Docker image is a special file system. In addition to providing programs, libraries, resources, and configuration files required by the container runtime, it also contains configuration parameters (for example, environment variables) for the runtime. The image does not contain any dynamic data and its contents are not changed after the build.
⭐ To sum up, the operation process of Docker is to go to the warehouse to pull the image to the local, and then run the image into a container by executing commands. This is why Docker is often called Docker dockers or dockers.
⭐ Is responsible for managing Docker images by the Docker Registry service (similar to warehouse administrator). Of course, not every mirror built by anyone is legitimate. What if someone builds a bad image? Therefore, the Docker Registry service is very strict in the management of images. The most commonly used Registry exposure service is the official Docker Hub, which is also the default Registry and has a large number of high quality official images.
4. How to use Docker
In fact, most people talk about Docker as a Docker Engine, which is just a container to build and run.
Docker File needs to be written before running the container, and the image can be generated through dockerFile before running the Docker container.
The Docker File defines everything you need to run an image, including the operating system and software installation location. In general, you don’t need to write Docker files from scratch, there are images written by engineers from all over the world in Docker Hub, you can modify based on this.
📚 In addition, Docker containers provide a way to build enterprise applications and business process applications that are easier to install, maintain, and move than traditional applications.
⭐Docker containers support isolation: Docker containers isolate applications not only from each other, but also from the underlying system. This not only makes the software stack cleaner, but also makes it easier for containerized applications to use system resources such as CPU, GPU, memory, I/O, network, etc. It also ensures that data and code remain independent.
⭐Docker containers support portability: Docker containers run on any machine that supports the container runtime environment. Applications do not have to be tied to the host operating system, so the application environment and the underlying operating environment can be kept clean and minimal. For example, MySQL with containers will run on most Linux systems that support containers, and all of the application’s dependencies are typically provided in the same container. Container-based applications can easily be migrated from on-Prem systems to the cloud, or from a developer’s laptop to a server, as long as the target system supports Docker and any third-party tools that may be used with it, such as Kubernetes.
⭐ In general, Docker container images must be built for a particular platform. For example, Windows containers do not run on Linux and vice versa; Previously, one way to get around this limitation was to start a virtual machine running the required operating system instance and run the container inside the virtual machine. However, the Docker team later devised a more elegant solution, called Manifest, that allowed images of multiple operating systems to be packaged in parallel. Although MANIFEST is still experimental, this hints at the potential for containers to be a cross-platform application solution as well as a cross-environment application solution.
⭐Docker container supports composability: Most business applications consist of several independent components, web server, database, and cache cache. The Docker container can combine these parts into an easily replaceable unit of functionality. Each part is provided by a different container and can be maintained, updated, exchanged, and modified independently of the other containers.
🔥 This is essentially a microservice model for application design. By dividing application functionality into independent, self-contained services, the microservices model provides a solution to the slow development of traditional and single rigid applications. Lightweight and portable containers make it easier to build and maintain microservices-based applications.
5. The need for orchestration systems spawned k8S
Although Docker provides an open standard for containerized applications, a new set of problems arise as more and more containers become available:
- How do you coordinate, schedule, and manage these containers?
- How can I upgrade my application without interrupting service?
- How do I monitor the health of my application?
- How do I batch restart programs in containers?
Solving these problems requires container choreography, which abstracts many machines into a single, supersized machine. K8s, Mesos and Docker Swarm are popular in the industry.
In the early stage of business development, there were only a few micro services, and Docker was enough at that time. However, as the business scale gradually expanded and containers became more and more, the work of operation and maintenance personnel became more and more complicated, it was necessary to arrange the system to rescue opers.
A mature container choreography system requires the following capabilities:
- Handle a large number of containers and users
- Load balancing
- Authentication and security
- Managed Service communication
- Multi-platform Deployment
🌊 K8S is a container-based cluster management platform. Its full name is Kubernetes.
Unlike Docker, K8S was created by Google, a well-known industry giant.
However, the K8S is not an entirely new invention. Its predecessor was The Borg system, which Google itself had been tinkering with for more than a decade. K8S is a Container coordinator developed by Google, which has been donated to CNCF and is now open source.
Leveraging years of experience and expertise in container management, Google has launched K8S for automated deployment of application containers that support a wide range of container tools including the now very popular Docker.
K8s is currently the market leader in container choreography, open source and published a series of standardized methods, the mainstream public cloud platform announced support.
First-class manufacturers are seizing the commanding heights of the standard, and a bunch of small manufacturers follow to play together, which is called ecology. What are the major domestic manufacturers doing? Grab the community groupon market, play the capital game, eh? !
6. K8s architecture and components
K8s consists of a large number of components, which communicate with each other through APIS. It can be summarized into three parts:
- controller manager
- nodes
- pods
K8s Cluster Architecture Diagram:
- The Controller Manager, or control plane, is used for schedulers and node status detection.
- Nodes, the collective computing power that makes up the Kubernetes cluster, is where the actual deployment container runs.
- Pods, the smallest unit of resources in a cluster.
The following figure shows how Kubernetes integrates Jenkins to implement CICD (a picture is worth thousands of words, so it needs a general understanding) :
The following diagram shows GitLab + Jenkins Pipeline + Doker + K8S + Helm automated deployment:
7. K8s and Docker Swarm
Docker Swarm and K8S are both container choreography technologies.
If you have to compare Docker to K8S, you should compare Docker Swarm to K8S.
Docker Swarm is Docker’s own solution for clustered deployment management, which has obvious advantages and can be more closely integrated into the Docker ecosystem.
Although Swarm is Docker’s son, it is still not as popular as K8S, which is largely due to commercial and ecological reasons. There are few explanations.
8. Docker and K8S are inseparable
Docker and K8S are so popular in the industry that they are already de facto standards.
Docker is a platform and tool for building, distributing, and running containers.
K8s is actually a Docker container orchestrated system that works around Pods. Pods are the smallest scheduling unit in the K8S ecosystem and can contain one or more containers.
Docker and K8S are fundamentally different technologies that work well together.
9. Development practice, soul questioning
(1) Why k8S? Can I use Docker without K8S?
You can. In fact, some small companies directly use Docker when their business is not too complicated. Although K8S has many benefits, it is known to be very complex and easy to do business without using IT. But K8S has to be enabled after the business reaches a certain scale!
(2) Can I use K8S without Docker?
K8s is just a container choreographer. What’s a container choreographer without? !
K8s is often used with Docker, but other containers such as RunC and Containerted can also be used.
Docker Swarm and K8S
Choose k8s. Docker Enterprise was sold to Mirantis at the end of 2019, and Mirantis announced that Docker Swarm would be phased out and k8S would be the default choreography tool.
🔥 reprint & reference:
- Juejin. Cn/post / 691356…
- Cloud.tencent.com/developer/n…
- zhuanlan.zhihu.com/p/53260098
We hope this article will help you 🧠 feel free to leave your thoughts in the comments 🌊, we will discuss and share 🔥