[docker series] practical problems and application scenarios solved by docker

insert image description here
The author intends to write a complete series of docker knowledge summary. This article is the first one, mainly to introduce what is docker? What are the main application scenarios? What problems were solved? How is it different from a virtual machine?


Docker is an open source container engine that is lightweight and portable, "build once, configure once and run anywhere". Developed in go language and complies with the apache2.0 protocol.

1. Problems existing in the traditional software industry

  • The development, production, and test environments are inconsistent, and services available in the development environment cannot be moved to production.
  • The migration cost between different environments is too high, and there is no unified software deployment packaging standard and packaging environment.
  • For distributed software continuous integration (testing, packaging, release, deployment, management) cycle is very long, it is difficult to automate and engineer.
  • Faced with the scenario of instantaneous user traffic increase, it is difficult to implement rapid deployment of distributed application service instances.

2. The relationship between container and docker

Docker is often referred to as the container technology of the software industry, so what are the similarities between docker and containers?

Traditional industry container Software Industry Docker
Load physical cargo Load and run the application service
Uniform specifications for easy handling The unity of the encapsulation environment (JDK and environment variables can be encapsulated in a docker image), which can follow certain rules for repeated and rapid automated installation and deployment
Environmental isolation, each company's container cargo is not mixed with other companies' cargo. In Linux, namespace technology is used for resource isolation, and cgroups technology is used for resource limitation. The containers do not affect each other.
Resource sharing, one container ship, carrying multiple containers A server can start multiple docker containers to share server resources
Have a complete logistics warehousing system The images in the docker image warehouse can be exported, imported, uploaded and downloaded

You can refer to my other article "[Dahua Cloud Native] The relationship between cooking dumplings and docker" , I think this article will be very helpful for you to understand docker.

Third, the difference between docker and virtual machine

Docker and virtual machines are similar in some application scenarios, but docker is not a virtual machine.

Docker is a virtualized container technology. The most fundamental difference between it and a virtual machine is that the docker container and the host share the Linux operating system kernel, and the operating system will not be installed on the host again . The essence of the running state of the docker container is the process on the host. Through namespace resource isolation and cgroups resource limitation, it looks like an independent virtual machine.

Contrast virtual machine docker container
startup speed Turtle speed (essentially start the operating system) Second speed (essentially starting a process)
Image size Take Ubuntu as an example, more than 1G Ubuntu:195M
Application Deployment Integration Usually installed manually Download image + start image (automatic)
memory access efficiency Slow, visit the virtual address first Basically the same as the host
CPU consumption The loss caused by the virtual operating system is large close to 0

Fourth, the application scenarios of docker

  • Once the docker image is built, the automatic packaging and integration of the application has been completed at one time. Docker images can be versioned, copied, shared, and modified, just like code management.
  • Through unified docker environment encapsulation (for example, the same version of JDK, the same environment variables, etc. are encapsulated in the image), the consistency of the application service running environment is guaranteed. Avoid the problem that it is easy to use in the test environment and fails to run in the production environment.
  • Docker can achieve startup times in seconds or even milliseconds. Greatly saves development, testing, and deployment time.
  • Because images can be downloaded and reused, and docker containers can be started quickly, combined with the container orchestration service (k8s), it can achieve elastic scaling and rapid expansion of large-scale distributed deployments.

V. Summary

Don't be discouraged if beginners have trouble understanding this section. In fact, the learning difficulty of docker is very low. With the deepening of learning, the above concepts are easy to understand.

insert image description here

Guess you like

Origin blog.csdn.net/hanxiaotongtong/article/details/123813977