1. What is Docker

Docker’s official website is www.docker.com/

Development history of Docker

Docker was an in-house project started by dotCloud founder Solomon Hykes while he was in France. Docker is an innovation based on dotCloud’s years of cloud technology. In March 2013, it was open source with Apache 2.0 license [Docker-soft], and the main project code was maintained on GitHub. The Docker project later joined the Linux Foundation and formed the Alliance for Advancing Open Containers (OCI).

Docker’s GitHub project has more than 46,000 stars and more than 10,000 forks. DotCloud even decided to change its name to Docker at the end of 2013 due to the popularity of the Docker project. Docker was originally developed and implemented on Ubuntu 12.04; Red Hat has supported Docker since RHEL 6.5. Google also uses Docker extensively in its PaaS products.

Docker uses Go language launched by Google for development and implementation, and is based on cgroup, Namespace of Linux kernel and Union FS of AUFS class to encapsulate and isolate processes, which is a virtualization technology at the level of operating system. Since a quarantined process is independent of the host and other quarantined processes, it is also called a container. The initial implementation was based on LXC, which was removed after version 0.7 in favor of home-grown libContainer, and has evolved to use runC and Containerd since 1.11.

Docker has further encapsulation on the basis of containers, from file system, network interconnection to process isolation and so on, which greatly simplifies the creation and maintenance of containers. Docker technology is lighter and faster than virtual machine technology.

2. Comparison between Docker technology and traditional virtualization technology

The following image compares Docker with traditional virtualization. The traditional virtual machine technology is to create a set of virtual hardware, run a complete operating system on it, and then run required application processes on the system. The application process in the container runs directly on the host kernel, without its own kernel and without hardware virtualization. Therefore, containers are much lighter than traditional virtual machines.

Docker technology

  • -Leonard: The Host OS is the operating system.
  • Bins: binary executables
  • Libs: Dependency packages
  • The container: the container

Virtualization technology

  • Hypervisor: Virtualization operating system (VIRTUAL Machine Monitor, VMM)
  • VM: indicates a VM
  • Guest OS: operating system (in a VM)

3. Advantages of Docker

More efficient use of system resources

Docker has a higher utilization of system resources because the container does not require additional overhead such as hardware virtualization and running a full operating system. Whether it is application execution speed, memory consumption or file storage speed, it is more efficient than traditional VIRTUAL machine technology. Therefore, a host with the same configuration can often run more applications than virtual machine technology.

Faster startup time

Traditional VIRTUAL machine technology usually takes several minutes to start application services, while Docker container applications can be started in seconds or even milliseconds because they run directly in the host kernel and do not need to start the complete operating system. Greatly saving the development, testing, deployment time.

Consistent operating environment

A common problem in development is environmental consistency. Some bugs are not found in the development process because the development environment, test environment, pre-release environment, and production environment are not consistent. 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”.

  • Development environment: Developers
  • Test environment: Tester
  • Pre-release environment (production drill) : The software and hardware configurations must be consistent with those of the production environment
  • Production environment:

Continuous delivery and deployment

The most desirable thing for development and operations (DevOps) people is a single build or configuration that can run anywhere.

With Docker, continuous integration, continuous delivery and deployment can be achieved by customizing application images. Developers can use Dockerfile for image building and Integration testing with Continuous Integration systems, while operations can quickly deploy the image directly into a production environment. Even automatic Deployment with Continuous Delivery/Deployment systems.

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.

Easier migration

Docker ensures the consistency of execution environment, making application migration easier. Docker can run on many platforms, whether physical machine, virtual machine, public cloud, private cloud, or even laptop, and its running results are consistent. Therefore, users can easily migrate an application running on one platform to another without worrying that the application will not run properly due to the change of the operating environment.

Easier maintenance and extension

Docker uses layered storage and image technology, which makes it easier to reuse the repeated parts of the application, easier to maintain and update the application, and it is also very simple to further expand the image based on the basic image. In addition, Docker team maintains a large number of high-quality official images together with various open source project teams, which can be used directly in the production environment and further customized as a basis, greatly reducing the cost of image production of application services.

Compare with traditional virtual machines

features The container The virtual machine
Start the Second level Minutes of class
The hard disk to use As a general rule, beMB As a general rule, beGB
performance Close to the native Weaker than the native
System support Supports thousands of containers on a single machine Usually dozens

4. Some terminology

4.1 Docker mirror

A Docker image is a read-only template.

For example, an image can contain a complete Ubuntu operating system environment with only Apache installed or other applications that the user needs.

Images can be used to create Docker containers.

Docker provides a very simple mechanism to create images or update existing images, and users can even download a ready-made image from someone else to use directly.

4.2 the Docker container

Docker uses containers to run applications.

A container is a running instance created from an image. It can be started, started, stopped, and deleted. Each container is an isolated, secure platform.

Think of the container as a simplified version of the Linux environment (including root user permissions, process space, user space, network space, and so on) and the applications running in it.

Note: The image is read-only, and the container creates a writable layer as the top layer at startup.

4.3 the Docker warehouse

A repository is a centralized place to store image files. The repository and the repository Registry are sometimes lumped together and not strictly distinguished. In fact, the repository registry server often hosts multiple repositories, each containing multiple images, each with a different tag.

Warehouse is divided into Public warehouse and Private warehouse two forms.

The largest public repository is Docker Hub, which houses a huge number of images for users to download. Domestic open warehouses include Docker Pool, which can provide mainland users with more stable and fast access.

Of course, users can also create a private repository within the local network.

Once the user has created his own image, he can use the push command to upload it to the public or private repository, so that the next time the image is used on another machine, he can just pull it from the repository.

Note: The concept of Docker repository is similar to Git, registry server can be understood as GitHub hosting service.