In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what is the concept of Docker", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the concept of Docker" this article.
Basic concepts of Docker: Image, Container, Repository
First, we start with knowing the container.
1.1 what is a container?
Let's first take a look at the more official explanation of the container.
A container is a container that packages software into standardized units for development, delivery, and deployment.
Container images are lightweight, executable, stand-alone software packages that contain everything the software needs to run: code, runtime environment, system tools, system libraries, and settings.
Containerization software is suitable for Linux and Windows-based applications and can run consistently in any environment.
Containers give software independence from external environmental differences (for example, differences in development and preview environments), helping to reduce conflicts between teams running different software on the same infrastructure.
Let's take a look at the more popular explanation of containers.
If you need a popular description of the container, I think the container is a place to store things, just like schoolbags can hold all kinds of stationery, wardrobes can put all kinds of clothes, shoe racks can put all kinds of shoes. What we are talking about in containers may be more biased towards applications such as websites, programs, and even system environments.
1.2 diagramming physical machines, virtual machines, and containers
The comparison between virtual machines and containers will be described in detail later. Here, we only deepen our understanding of physical machines, virtual machines and containers through online pictures.
Physical machine:
Virtual machines:
Container:
From the above three abstract diagrams, we can roughly summarize by analogy that containers virtualize the operating system rather than hardware, and the containers share the same set of operating system resources. Virtual machine technology is to virtualize a set of hardware and run a complete operating system on it. As a result, the isolation level of the container is slightly lower.
I believe that through the above explanation, we have a preliminary understanding of the concept of container, which is both unfamiliar and familiar. Let's talk about some concepts of Docker.
Second, let's talk about some concepts of Docker.
2.1What is Docker?
To be honest, it's not easy to say what Docker is. Here are four points to show you what a Docker is.
Docker is the world's leading software container platform.
Docker is developed and implemented by Go language released by Google. Cgroup,namespace based on Linux kernel and UnionFS of AUFS class encapsulate and isolate the process, which belongs to the virtualization technology at the operating system level. Because the isolated process is independent of the host and other isolated processes, it is also called a container. The initial implementation of Docke is based on LXC.
Docker automates repetitive tasks, such as building and configuring the development environment, freeing developers to focus on what really matters: building great software.
Users can easily create and use containers and put their applications into containers. Containers can also be versioned, copied, shared, and modified, just like managing ordinary code.
2.2 Docker thought
Container
Standardization: ① transport mode ② storage mode ③ API interface
Isolation
2.3 characteristics of Docker containers
Light weight
Multiple Docker containers running on a single machine can share the machine's operating system kernel; they can start quickly and take up very little computing and memory resources. Mirrors are constructed through the file system layer and share some common files. In this way, you can minimize disk usage and download images more quickly.
Standard
Docker containers are based on open standards and can run on all major Linux versions, Microsoft Windows, and any infrastructure, including VM, bare metal servers, and the cloud.
Safety
The isolation that Docker gives to applications is not limited to isolation from each other, but also independent of the underlying infrastructure. Docker provides the strongest isolation by default, so if there is a problem with the application, it is only a single container problem, not the entire machine.
2.4 Why use Docker
Docker's image provides a complete runtime environment other than the kernel, ensuring the consistency of the application runtime environment, so that there will be no more problems such as "this code is fine on my machine";-- consistent runtime environment
Can achieve seconds, or even milliseconds start-up time. It greatly saves the time of development, testing and deployment. -- faster startup time
Avoid public servers, resources will be easily affected by other users. -isolation
Be good at dealing with centralized server pressure;-- flexible scaling, rapid expansion
Applications running on one platform can be easily migrated to another without having to worry about the failure of the application due to changes in the running environment. -- easy to migrate
Using Docker, you can customize application images to achieve continuous integration, continuous delivery, and deployment. -continuous delivery and deployment
When it comes to containers, we have to compare them with virtual machines. As far as I am concerned, it doesn't matter who will replace whom, but the two can coexist harmoniously.
Three-container VS virtual machine
To put it simply: containers and virtual machines have similar advantages of resource isolation and allocation, but their functions are different, because containers virtualize the operating system, not hardware, so containers are easier to migrate and more efficient.
3.1 comparison between the two
The traditional virtual machine technology is that after a set of hardware is virtualized, a complete operating system is run on it, and then the required application processes are run on the system; while the application processes in the container run directly in the host kernel, and there is no kernel in the container, and there is no hardware virtualization. Therefore, the container is lighter than the traditional virtual machine.
3.2 Container and Virtual Machine (VM) Summary
A container is an application layer abstraction used to package code and dependent resources together. Multiple containers can run on the same machine and share the operating system kernel, but each runs in user space as separate processes. Compared with the virtual machine, the container takes up less space (the container image size is usually only a few tens of megabytes), and the startup can be completed in an instant.
A virtual machine (VM) is a physical hardware layer abstraction used to turn a server into multiple servers. The hypervisor allows multiple VM to run on a single machine. Each VM contains a complete set of operating systems, one or more applications, necessary binaries, and library resources, thus taking up a lot of space. And VM starts very slowly.
Through the Docker official website, we know so many advantages of Docker, but there is no need to completely deny virtual machine technology, because the two have different usage scenarios. Virtual machines are better at completely isolating the entire operating environment. For example, cloud service providers often use virtual machine technology to isolate different users. Docker is often used to isolate different applications, such as front-end, back-end, and databases.
3.3Container and virtual machine (VM) can coexist
As far as I am concerned, it doesn't matter who will replace whom, but the two can coexist harmoniously.
There are three very important basic concepts in Docker. If you understand these three concepts, you will understand the entire life cycle of Docker.
Four basic concepts of Docker
Docker includes three basic concepts:
Mirror (Image)
Container (Container)
Warehouse (Repository)
After understanding these three concepts, we can understand the whole life cycle of Docker.
4.1Mirror (Image)-A special file system
The operating system is divided into kernel and user space. For Linux, after the kernel starts, the root file system is mounted to provide user space support. The Docker image (Image) is the equivalent of a root file system.
Docker image is a special file system, which not only provides programs, libraries, resources, configuration and other files needed by the container, but also contains some configuration parameters (such as anonymous volumes, environment variables, users, etc.) prepared for the runtime. The mirror does not contain any dynamic data, and its content will not be changed after it is built.
When Docker is designed, it makes full use of the technology of Union FS and designs it as a hierarchical storage architecture. Mirroring is actually made up of multi-tier file systems.
When the image is built, it is built layer by layer, and the former layer is the foundation of the latter layer. After each layer is built, there will be no change, and any change on the latter layer will only happen at your own level. For example, deleting a file in the previous layer does not actually delete the file in the previous layer, but only marks the file as deleted at the current layer. Although the file will not be seen when the final container runs, it will actually follow the image all the time. Therefore, when building the image, you need to be extra careful, each layer contains only what needs to be added by that layer, and any extra stuff should be cleaned up before the end of the layer construction.
The characteristics of hierarchical storage also make the reuse and customization of images easier. You can even use the previously built image as the base layer, and then further add new layers to customize the content you need and build a new image.
4.2Container (Container)-mirroring the runtime entity
The relationship between Image and Container is like classes and instances in object-oriented programming. Mirrors are static definitions and containers are entities that mirror runtime. Containers can be created, started, stopped, deleted, paused, and so on.
A container is essentially a process, but unlike a process executed directly in the host, the container process runs in its own independent namespace. As mentioned earlier, mirrors use tiered storage, and so do containers.
The life cycle of the container storage layer is the same as that of the container. When the container dies, the container storage layer also dies. Therefore, any information saved in the container storage layer is lost when the container is deleted.
As required by Docker best practices, the container should not write any data to its storage tier, and the container storage tier should remain stateless. All file writing operations should use data volumes (Volume) or bind host directories. Reads and writes at these locations will skip the container storage layer and read and write directly to the host (or network storage), resulting in higher performance and stability. The life cycle of the data volume is independent of the container, the container dies, and the data volume does not die. Therefore, after using the data volume, the container can delete and re-run at will without losing the data.
4.3Warehouse (Repository)-A place where images are centrally stored
After the image is built, it can easily run on the current host, but if you need to use this image on other servers, we need a centralized service to store and distribute images, such as Docker Registry.
A Docker Registry can contain multiple repositories (Repository); each warehouse can contain multiple tags (Tag); each tag corresponds to an image. So: the image repository is the place where Docker centrally stores image files, similar to the code repository we used before.
Usually, a repository will contain images of different versions of the same software, and tags are often used to correspond to different versions of the software. We can specify which version of the software is mirrored by the format of:. If no label is given, latest will be used as the default label.
Here is a supplement to the concepts of Docker Registry public service and private Docker Registry:
The Docker Registry public service is a Registry service that is open to users and allows users to manage images. In general, such public services allow users to upload and download public images for free, and may provide fee-based services for users to manage private images.
The most commonly used Registry public service is the official Docker Hub, which is also the default Registry, and has a large number of high-quality official images at https://hub.docker.com/. It may be slow to access Docker Hub in China, and there are some cloud service providers in China that provide public services similar to Docker Hub. For example, hourly cloud image library, NetEase cloud image service, DaoCloud image market, Ali cloud image library, etc.
In addition to using public services, users can also build private Docker Registry locally. Docker officially provides Docker Registry image, which can be used directly as a private Registry service. The open source Docker Registry image only provides a server-side implementation of Docker Registry API, which is sufficient to support docker commands without affecting the use. However, it does not include graphical interface, as well as advanced functions such as image maintenance, user management, access control and so on.
The concept of Docker is basically over. Finally, let's talk about: Build, Ship, and Run.
5 final talk: Build, Ship, and Run
If you search the Docker website, you will find the following words: "Docker-Build, Ship, and Run Any App, Anywhere". So what on earth are Build, Ship and and Run doing?
Build (build image): an image is like a container, including files, running environment, and other resources.
Ship (Transport Image): transport between mainframe and warehouse, where the warehouse is like a super wharf.
Run (running image): the running image is a container, and the container is the place where the program runs.
The Docker process is to go to the repository and pull the image locally, and then use a command to run the image into a container. Therefore, we often refer to Docker as dock workers or dock stevedores, just like the Chinese translators and porters of Docker.
The above is all the content of this article "what is the concept of Docker?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.