Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages and disadvantages of Docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what are the advantages and disadvantages of Docker". In daily operation, I believe many people have doubts about the advantages and disadvantages of Docker. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the advantages and disadvantages of Docker?" Next, please follow the editor to study!

Problems solved by Docker:

Because different machines have different operating systems, as well as different libraries and components, a large number of environment configuration operations are required to deploy an application to multiple machines.

Docker mainly solves the problem of environment configuration. It is a virtualization technology that isolates processes, which are independent of the host operating system and other isolated processes. Using Docker, you can deploy existing applications to other machines without modifying the application code and without requiring developers to learn the technology in a specific environment.

Comparison with virtual machines:

Virtual machine is also a kind of virtualization technology. The biggest difference between virtual machine and Docker is that it is realized by simulating hardware and installing operating system on the hardware.

Starting speed

To start a virtual machine, you need to start the operating system of the virtual machine before starting the application, which is very slow.

Starting Docker is equivalent to starting a process on the host operating system.

Take up resources

Virtual machine is a complete operating system, which needs a lot of disk, memory and CPU resources. One machine can only open dozens of virtual machines.

On the other hand, Docker is just a process, which only needs to package the application and related components, and takes up very little resources at run time. A machine can open thousands of Docker.

Images and containers:

A mirror is a static structure that can be thought of as an object-oriented class, and the container is an instance of the mirror.

The image, which contains the code and other components required by the container runtime, is a hierarchical structure, with each layer being read-only layers. When building an image, it is built layer by layer, and the former layer is the foundation of the latter layer. This hierarchical storage structure of the image is very suitable for the reuse and customization of the image.

When building a container, a writable layer (writable layer) is added to the image to hold the changes made while the container is running.

Advantages and disadvantages:

1. Easy to deploy

You must still remember that when we first learned to program, the step of setting up the environment often took us hours, and one of the minor problems may take a long time to solve. You will also get help from other members of the team on environmental building. With containers, this becomes very easy, and your development environment is just the address of one or more container images, and at most you need an execution script that controls the deployment process. Or further put your environment image and image script into a git project, publish it to the cloud, and pull it locally if needed.

# git clone https://github.com/my-project # sh. / my-build-boot.sh

At present, our team basically uses this solution to build a local development environment, and collates it into internal technical documents, which gradually precipitates into the wealth of the team.

two。 Deployment security

When we receive a bug feedback, many times the first reaction must be "I am good locally"! The occurrence of this situation lies in the inconsistency of the environment, our debugging in the development process often can not guarantee the problems of other environments, but we have to pay for it, which is really distressing. With containers, this rarely happens. Through container technology, we can keep the version and dependency of the development environment, the test environment and the production environment unified, and ensure that the code is executed in a highly unified environment. The unity of the test environment can also solve the environmental requirements of the CI process.

Today, with the increasing demand for distributed technology and capacity expansion, if operators can use container technology to deploy the environment, it will not only save a lot of deployment time, but also minimize many errors caused by manual configuration of the environment.

3. Good isolation

Whether it is development or production, often we may need to run multiple services on one machine, and the dependency configuration of each service is different. If two applications need to use the same dependency, or there will be some conflicts between the dependencies needed by the two applications, problems will easily occur at this time. Therefore, it is best to isolate different services provided by different applications on the same server. Containers have natural advantages in this respect. Each container is an isolated environment. The container can provide all the services you require from within the container. This high cohesion performance can achieve rapid separation of problematic services, fast troubleshooting and timely processing in some complex systems. (of course, it should be noted that this isolation is only compared to the server, and virtual machine technology should have better isolation.)

4. Quick rollback

The rollback mechanism before the container generally needs to be redeployed based on the previous version of the application and replace the current problem version. In the early days, it might have been a complete development-to-deployment process, which often took a long time to implement. In a git-based environment, it is possible to roll back a history commit and then redeploy. None of this is fast enough compared to container technology and may cause new problems (because they are based on changes to the new version). Container technology is born with rollback properties, because every history container or image will be saved, and replacing a container or a history image is very fast and easy.

5. Low cost

This is probably the most obvious and useful advantage. Before the advent of containers, we often needed a new server or a virtual machine to build an application. The purchase cost and operation and maintenance cost of the server are very high, while the virtual machine needs to take up a lot of unnecessary resources. In contrast, container technology is much smaller and lighter, which only needs to give a container the dependency needed to build applications inside, which is also the main reason for the rapid development of container technology.

6. Lower management cost

With the continuous popularization and development of container technology, container management and choreography technology has also been developed. Choreography tools such as Docker Swarm,Kubernetes and Mesos are also being updated iteratively, which makes container technology have more possibilities and more room to play in the production environment. With the development of the environment, the cost of using and learning containers such as docker is becoming lower and lower, and it has become a choice for more developers and enterprises.

Having said so many advantages, the container also has some problems that have not been solved. The previous generation scheme is basically a cloud scheme based on virtual machine technology, which can effectively increase the efficiency of the server and achieve the purpose of cost saving, while container technology further optimizes the utilization rate of resources. However, there are still some issues that we need to consider when choosing a service resource architecture scenario:

1. Isolation

Virtual machine technology based on hypervisor is better than container technology in isolation, and their system hardware resources are completely virtualized. When a virtual machine has system-level problems, it often does not spread to other virtual machines on the same host. But containers are different. Containers share the same operating system kernel and other components, so when an attack occurs, it is more likely to affect other containers through the underlying operating system. Of course, this problem can be solved by deploying containers in virtual machines, but this leads to new problems, such as increased costs and the following problems: performance.

two。 Performance

Both virtual machines and containers use different technologies to encapsulate and isolate the application itself to a certain extent, and a lot of efforts have been made to reduce the coupling between the application and the application and between the application and the environment. But randomly, there will be more network connection forwarding and data interaction, which will not be obvious on low concurrency systems. And it often does not become an application bottleneck (it may be scattered on different virtual machines or servers), but when the containers under the same virtual machine or server need higher concurrency support, that is, when the concurrency problem becomes an application bottleneck, the container will magnify this problem. Therefore, not all application scenarios are applicable to container technology.

3. Storage scheme

Containers are not born to serve OS abstraction, which is the biggest difference between virtual machines and virtual machines. Such genes mean that containers are born to make more efforts for the application environment, and the scalability of containers is also based on this disposable feature of containers. In contrast, persistent storage solutions are needed. The solution provided by the docker container is to use the volume interface to form data mapping and transfer in order to achieve the purpose of data persistence. But this will also lead to a waste of some resources and more interactions, whether it is mapped to the host or to the network disk, is the second-best solution.

At this point, the study of "what are the advantages and disadvantages of Docker" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report