Understand and publish images

 

3.1, Understanding of images

  1. An image is a lightweight, executable, independent software package that contains all the content needed to run a certain software. We package applications and configurations into a complete, deliverable, and deployable operating environment, including code, libraries required for runtime, environment variables, and configuration files. This packaged operating environment is the image image file.
  2. Only through image files can docker container instances be generated.

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 file system modifications as a single submission to be superimposed layer by layer, and different directories can be mounted under the same virtual file system.
  2. Images can be inherited through layering, and various specific application images can be made based on the basic image.

Characteristics of Union File System: Multiple file systems can be loaded at the same time, but from the outside, only one file system can be seen; Union loading will superimpose each layer of file system, so that the final file system will contain files and directories of all layers.

3.3, Image layering

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

image-20230424154810939

 

3.3.1, Layered Understanding

3.3.2, The benefits of using layered docker images

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

3.4, Create and publish images

3.4.1, Create images

Method 1, submit an image from the container:

Method 2: Dockerfile to create an image:

 

3.4.2. Publish images

A docker repository is a place where image files are stored. The largest public repository is dockerhub (https://hub.docker.com/), which stores a large number of images for users to download.

Steps to publish images 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 specification for publishing an image to docker hub is:

For example, my registered username is: pengan88, so I need to modify the image name first

  1. Log in to docker hub to publish the image:
  1. Visit docker hub to see that it has been successfully released

image-20230424152530278