1. What is Docker?
Docker is an open source application container engine based on the Go language. Developers can package their applications and related dependencies into a portable image file, and then publish it to the server.
2. What problem did Docker solve?
2.1 Inconsistent operating environment
Docker technology mainly solves the problem that a series of programs cannot run normally due to the inconsistent development environment. For example, the developers tested and packaged and deployed in their own environments, but a series of problems occurred when the delivery and maintenance were launched. The developer said that everything here is normal, the operation and maintenance staff said that there is a problem with the developer code, and so on.
Using Docker, the developer's application code and development environment configuration can be packaged into a container and then ported to the Linux system, which solves the "run on my machine" problem.
2.2 The mutual influence between users in the public server
Docker is isolated. In a public Linux system, if a certain program consumes system resources very much, then this program can easily affect the normal operation of other programs. So later, virtual machine technology appeared, and each virtual machine was isolated from each other, and different users did not interact with each other. But compared to虚拟机
this heavyweight virtualization solution, Docker has the advantages of lightweight virtualization and low performance consumption.
2.3 Repeated installation environment on the server
Many Java applications now use distributed cluster deployment. Clustering means multiple servers. For the normal operation of the application, we may need the operating environment on each server to be the same. We need to install the operating environment once for a server. If there are few machines, what if there are dozens of them?
Docker can easily solve such repeated operation problems. The software is installed together with the environment, saving time and effort.
3. Docker philosophy
Build,Ship and Run Any App,Anywhere
It is Docker's goal philosophy, that is 随时随地构建、安装、运行在任何地点
.
4. The three major elements of Docker?
Three elements of Docker:
element | description |
---|---|
Mirror | The Docker image (Image) is a read-only template. The image can be used to create Docker containers, and one image can create many containers. |
container | You can think of the container as a simple version of the Linux environment (including root user permissions, process space, user space, network space, etc.) and applications running in it. One container runs one service. |
warehouse | Docker Hub is similar to GitHub. Docker Hub is a central repository of image files. Developers package the local operating environment as an image file and upload it to Docker Hub. Then O & M downloads the image file from here to run, seamlessly. |
For example, in the Linux system, we installed it on one machine. Redis、Mysql
If the project is a cluster deployment, you need to install the software on another machine. If it is a traditional installation method, it is more troublesome, and some configuration files need to be modified. After using Docker technology, we Redis
package the running environment as an image file, and after running the image file on another machine, we can install a Redis
running environment that is exactly the same . So as to achieve 一次封装,到处运行
the effect.
5. Virtual machines and containers
Virtual machine (virtual machine) is a solution with environment installation. It can run another operating system in one operating system, for example, we can run linux system in windows system. The application program is not aware of this. For the windows system, the linux system is one of his software. Delete it if you don't need it, it won't have any effect. The virtual machine completely simulates another set of complete system: memory, hard disk, sound card ..., occupies a lot of resources, and it is really slow to start up ~~ in
view of the shortcomings of virtual machine technology, Linux has developed another virtual Technology: Linux Containers (Linux Containers, abbreviated as LXC).
The Linux container virtualizes the operating system, which is different from VM virtualizing a complete computer. With a container, you can package all the resources required by the software into an isolated container. The container only needs the library resources and configuration required for the software to work. What printers and sound cards are not suitable for the soft armor. So the system is more lightweight than the virtual machine and ensures deployment in any environment. Can be run in the middle.
Docker container | virtual machine | |
---|---|---|
operating system | Share OS with host | Run the virtual machine OS on the host OS |
Storage size | Small mirror image for easy storage and transmission | Huge image (vmdk, vid, etc.) |
Running performance | Almost no additional performance loss | Operating system extra CPU, memory consumption |
Portability | Lightweight, flexible and adaptable to Linux | Cumbersome and highly coupled with virtual technology |
Hardware affinity | For software developers | For hardware maintainers |
Deployment speed | Fast, seconds | Slower, more than 10s |
6. Container technology advantage?
The use of containers to deploy applications is called containerization, and containers are widely praised by the development community because of the following characteristics:
characteristic | description |
---|---|
flexible | Even the most complex applications can be containerized |
portability | Developers can build locally, then deploy to cloud services and run |
Lightweight | The container utilizes and shares the host core, which is more efficient than the virtual machine in terms of system resources |
Loosely coupled | The container is highly self-sufficient and can be replaced or upgraded without damaging other containers |
Scalable | Can add and automatically distribute container copies in the data center |
Safety | The container will apply active constraints and isolation to the process without any configuration from the user |