3、Docker images deeply understand and publish images

 

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

3.1、image understanding

  1. An image is a lightweight, executable stand-alone software package that contains everything needed to run a piece of software. We package applications and configurations into a ready, deliverable, deployable runtime environment, including code, libraries, environment variables and configuration files required for runtime, and this large package runtime environment is the image image file.

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

3.2、UnionFS(Federated file systems)

1.Union file system (UnionFS) is a hierarchical, lightweight, high-performance file system, it is the basis of docker images, and supports the modification of the file system as a commit to overlay layer by layer, while different directories can be mounted under the same virtual file system.

2.The image can be inherited through layering, and based on the basic image, various specific application images can be made.

Features of the Union file system: load multiple file systems at the same time, but from the outside, only one file system can be seen; Federated loading overlays the layers of file systems so that the final file system contains files and directories for all layers.

3.3、image layering

When downloading an image, pay attention to the downloaded log output, you can see that it is downloading layer by layer:

image-20230424154810939

3.3.1、hierarchical understanding

3.3.2、Docker images should use layering benefits

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

3.4、Make and publish images

3.4.1、Make an image

Method 1: Submit an image from the container:

Method 2: Make an image from a dockerfile:

3.4.2、Publish the image

The docker repository is a centralized storage place for image files. The largest public repository is Docker Hub (https://hub.docker.com/), which houses a huge 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 log in normally

image-20230424151714735

  1. Use the tag command to modify the image name

The specification for publishing an image to docker hub is:

For example, my registered username here is: pengan88, then you must first change the image name

  1. Log in to Docker Hub to publish the image:

5、Visit Docker Hub to see that it has been successfully released

image-20230424152530278