One of the biggest hassles of software development is environment configuration. Especially the evil Windows, often appear some strange problems. Especially for new recruits, we need to install a lot of environment, for example, our team, the back-end is Go, I don’t know what environment to install. Front end, the need to install PHP, redis, node, nginx, mysql these 5. Download and install one by one? Also note that version issues are annoying.

At this time, you can write a Docker configuration, the new employee, according to the document all the way down, if the wind is smooth, it can be installed in an hour.

What a comfortable (@ο@) wow!

Here are some introductions to Docker

I. Problems solved

Because different machines have different operating systems, as well as different libraries and components, deploying an application to multiple machines requires a lot of environment configuration.

Docker mainly solves the problem of environment configuration. It is a virtualization technology that isolates processes. The isolated processes are independent of the host operating system and other isolated processes, which we call containers. Docker allows existing applications to be deployed on other machines without modifying application code and without requiring developers to learn the techniques of a particular environment. Applications run in containers that can be easily copied.

2. Comparison with VIRTUAL machines

Virtual machine is also a virtualization technology. The biggest difference between it and Docker is that it emulates hardware and installs an operating system on the hardware.

startup

To start a VM, you need to start the VM OS first and then the application. This process is very slow.

Starting Docker is like starting a process on the host operating system. As fast as you turn on a guy for dinner.

Occupancy resources

A VM is a complete operating system that consumes a large amount of disks, memory, and CPUS. Only dozens of VMS can be enabled on a vm.

However, Docker is just a process, which only needs to package the application and related components, and takes up few resources when running. A machine can open thousands of Dockers.

Three, advantage

In addition to fast startup speed and less resource occupation, Docker has the following advantages:

Easier to migrate

A common problem in development is environmental consistency. Because the development environment, test environment, and production environment are inconsistent, some bugs are not found in the development process. The image of Docker provides a complete runtime environment in addition to the kernel, ensuring the consistency of the application running environment, so that there will no longer be “no problem with this code on my machine”.

Easier to maintain

The most desirable thing for development and operations (DevOps) people is a single build or configuration that can run anywhere. Layering and mirroring make it easier for applications to reuse repetitive parts. The higher the reuse, the easier the maintenance.

Easier to scale

New images can be further extended using the base image, and there are plenty of images available in the official and open source communities that can be easily extended to get the desired image.

Four, use scenarios

Continuous integration

Continuous integration refers to the frequent integration of code into the trunk so that errors can be found more quickly.

Docker is lightweight and isolated. Code integration into one Docker will not affect other Dockers.

With Docker, continuous integration, continuous delivery and deployment can be achieved by customizing application images. Developers can build images using Dockerfile and integrate them with the continuous integration system for integration testing, while operations can quickly deploy images directly into production or even deploy them automatically with the continuous deployment system.

Moreover, using Dockerfile to make image construction transparent, not only the development team can understand the application operating environment, but also facilitate the operation and maintenance team to understand the application operating conditions, helping to better deploy the image in the production environment.

Provide scalable cloud services

Docker can be easily added or subtracted, depending on the load on the application.

Build the microservice architecture

Docker’s lightweight nature makes it ideal for deploying, maintaining, and composing microservices.

Mirrors and containers

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

The image contains the code and other components needed by the container to run. It is a layered structure, with each layer read-only layers. When a mirror is built, it is built layer by layer, with the previous layer being the foundation for the next. The hierarchical storage structure of images is suitable for reuse and customization of images.

When a container is built, a writable layer is added to the image to hold changes made during the container’s operation.