3. In-depth understanding of docker images and publishing images

 

The operating environment and software and hardware reference configuration are as follows:

3.1. Understanding of mirroring

  1. An image is a lightweight, executable independent software package that contains everything needed to run a certain software. We package the application and configuration into a formed, deliverable, and deployable operating environment, including code, libraries required for runtime, environment variables, and configuration files, etc. This large packaged operating environment is an image image file.

  2. Docker container instances can only be generated through image files.

 

3.2, UnionFS (Union File System)

  1. Union File System (UnionFS) is a layered, lightweight, high-performance file system. It is the basis of docker images and supports modifications to the file system to be superimposed layer by layer as a single submission. At the same time, different directories can be mounted under the same virtual file system.

  2. Images can be inherited through layering. Based on the basic image, various specific application images can be produced.

Features of the Union file system: multiple file systems are loaded at the same time, but from the outside, only one file system can be seen; Union loading will superimpose the file systems of each layer, so that the final file system will contain all layers. Files and directories.

 

3.3. Mirror layering

When downloading an image, pay attention to the download log output. You can see that it is downloading layer by layer:

image-20230424154810939

 

3.3.1. Hierarchical understanding

 

3.3.2. The benefits of layering docker images

Resource sharing, for example, if multiple images are built from the same Base image, then the host only needs to keep one base image on the disk, and only one base image needs to be loaded in the memory, so that all Containers serve, and each layer of the image can be shared.

 

 

3.4. Making and publishing images

 

3.4.1. Make an image

Method 1. Submit an image from the container:

Method 2. Create image using dockerfile:

 

3.4.2. Release image

The docker repository is a centralized place for storing image files. The largest public repository is docker hub (https://hub.docker.com/), which stores a large number of images for users to download. Domestic public warehouses include Alibaba Cloud, NetEase Cloud, etc.

 

Steps to publish the image to docker hub:

  1. Address: https://hub.docker.com/, register an account first

  2. Ensure that the account can be logged in normally

image-20230424151714735

  1. Use the tag command to modify the image name.

The specifications for publishing images to docker hub are:

For example, my registered user name here is: pengan88, then I need to change the image name first.

4、登录docker hub发布镜像:

5、访问docker hub可查看到已经发布成功

image-20230424152530278