We give a brief introduction to Docker from three aspects

  1. What is a Docker?
  2. Why Docker?
  3. What kind of problem does Docker solve?

I believe that those who have read this article have already had a preliminary understanding of Docker. Only when we fully understand the wonders of Docker, can we better use it later. Next, we will talk about the three most important basic concepts of Docker, mirror, container and warehouse

The mirror

Before we get to the concept of mirroring, we need to take a brief look at UnionFS, which is the basis of Docker mirroring. UnionFS is a layered, lightweight, and high-performance file system that allows changes to the file system to be added layer by layer as a single commit. At the same time, different directories can be mounted to the same virtual file system. Images can be integrated through layers. We can make a variety of application images to meet our needs based on a basic image.

At the same time, for a thin OS, rootfs can be very small, with common commands. At the same time, the underlying layer is directly used as the kernel of the operating system, so the volume of an image in Docker can be relatively small, for example, a complete version of centos may require several gigabytes. But centos in Docker is only about 300M.

The official definition of docker images is as follows:

An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image which is based on the ubuntu image, but installs the Apache web server and your application, As well as the configuration details needed to make your application run. ‘

The image is a read-only template with instructions to create a Docker container. Often, one image is based on another, and some additional customization is required. For example, you can build an image based on an Ubuntu image, but install the Apache Web server and your application, along with the configuration details needed to get your application running.

PS: One image can create multiple containers.

Container:

Containers are running instances created with images.

Each container can be started, started, stopped, and deleted, and isolated from each other to keep the application safe while it is running.

We can think of the container as a stripped-down version of the Linux operating system, including root user privileges, process space, user space, network space, and so on, plus the applications running on top of it.

For example, if we create a container based on the mysql image, this container is not a single mysql program, but mysql is also installed and running in the Linux environment within our container.

Relationship between container and image:

Before we get to that, let’s take a look at this Java code:

Person p = new Person();
Person p1 = new Person();
Person p2 = new Person();
Copy the code

The mirror here is our Person, and the container is each instance of the Person class. A Person can create multiple instances, and an image can create multiple containers.

Warehouse:

A Repository is relatively easy to understand. A Repository is a centralized place for storing image files.

Warehouses are divided into public warehouses and private warehouses. At present, the largest warehouse in the world is Docker’s official Docker Hub

Due to some irresistible factors, it is very painful for us to download the public image from Docker Hub. You can refer to the feeling when you download the official image from Baidu. Therefore, we generally use the mirror warehouse of Ali Cloud or netease Cloud in China.

The relationship between them is as follows:

Conclusion:

Today, we simply describe the three elements of Docker, image, container and warehouse, in the later learning we will often see the two concepts of image and container, but also write our own DockerFile to build our custom image file.

Finally, the notes have been synced to Github(welcome star) : github.com/hanshuaikan…