Long-Term Supported Versions

    Innovation Versions

      Image Management



      Syntax: docker build [options] path | URL | -

      Function: Builds an image using the Dockerfile in the specified path.

      Parameter description: Common parameters are as follows. For details about more parameters, see the docker help build command section.

      Table 1 Parameter description




      Deletes containers generated during the build process even if the build is not successful.


      Builds cache without using cache.

      -q, --quiet=false

      Prevents the redundant information generation during the build.


      Deletes the container generated during the build after the build is successful.

      -t, --tag=""

      Tag name of the image generated during the build.


      Configures the build parameters.


      Image-related parameters. The description of each parameter is similar to that of the create command.


      Container isolation method.


      Obtains the latest image during the build.

      Dockerfile Command

      Dockerfile is used to describe how to build an image and automatically build a container. The format of all Dockerfile commands is instruction arguments.


      FROM Command

      Syntax: FROM image or FROM image:tag

      Function: Specifies a basic image, which is the first command for all Dockerfile files. If the tag of a basic image is not specified, the default tag name latest is used.


      RUN Command

      Syntax: RUN command (for example, run in a shell - `/bin/sh -c`) or

      RUN [executable, param1, param2 ... ] (in the exec command format)

      Function: Runs any command in the image specified by the FROM command and then commits the result. The committed image can be used in later commands. The RUN command is equivalent to:

      docker run image command

      docker commit container_id



      The number sign (#) is used to comment out.


      MAINTAINER Command

      Syntax: **MAINTAINER **name

      Function: Specifies the name and contact information of the maintenance personnel.


      ENTRYPOINT Command

      Syntax: ENTRYPOINT cmd param1 param2... or ENTRYPOINT ["cmd", "param1", "param2"...]

      Function: Configures the command to be executed during container startup.


      USER Command

      Syntax: **USER **name

      Function: Specifies the running user of memcached.


      EXPOSE Command

      Syntax: EXPOSE port [port...]

      Function: Enables one or more ports for images.


      ENV Command

      Syntax: ENV_ key value_

      Function: Configures environment variables. After the environment variables are configured, the RUN commands can be subsequently used.


      ADD Command

      Syntax: ADD_ src dst_

      Function: Copies a file from the src directory to the dest directory of a container. src indicates the relative path of the source directory to be built. It can be the path of a file or directory, or a remote file URL. dest indicates the absolute path of the container.


      VOLUME Command

      Syntax: VOLUME ["mountpoint"]

      Function: Creates a mount point for sharing a directory.


      WORKDIR Command

      Syntax: **workdir **path

      Function: Runs the RUN, CMD, and ENTRYPOINT commands to set the current working path. The current working path can be set multiple times. If the current working path is a relative path, it is relative to the previous WORKDIR command.


      CMD command

      Syntax: CMD ["executable","param1","param2"] (This command is similar to the exec command and is preferred.)

      CMD ["param1","param2"] (The parameters are the default parameters for ENTRYPOINT.)

      CMD command param1 param2 (This command is similar to the shell command.)

      Function: A Dockerfile can contain only one CMD command. If there are multiple CMD commands, only the last one takes effect.


      ONBUILD Commands

      Syntax: ONBUILD [other commands]

      Function: This command is followed by other commands, such as the RUN and COPY commands. This command is not executed during image build and is executed only when the current image is used as the basic image to build the next-level image.

      The following is a complete example of the Dockerfile command that builds an image with the sshd service installed.

      FROM busybox
      ENV  http_proxy
      ENV  https_proxy
      RUN apt-get update && apt-get install -y openssh-server
      RUN mkdir -p /var/run/sshd
      EXPOSE 22
      ENTRYPOINT /usr/sbin/sshd -D


      1. Run the following command to build an image using the preceding Dockerfile:

        $ sudo docker build -t busybox:latest
      2. Run the following command to view the generated image:

        docker images | grep busybox


      Syntax: docker history [options] image

      Function: Displays the change history of an image.

      Parameter description:

      -H, --human=true

      --no-trunc=false: Does not delete any output.

      -q and --quiet=false: Display only IDs.


      $ sudo docker history busybox:test
      IMAGE               CREATED             CREATED BY          SIZE                COMMENT
      be4672959e8b        15 minutes ago      bash                23B
      21970dfada48        4 weeks ago                             128MB               Imported from -



      Syntax: docker images [options] [name]

      Function: Lists existing images. The intermediate image is not displayed if no parameter is configured.

      Parameter description:

      -a and --all=false: Display all images.

      -f and --filter=[]: Specify a filtering value, for example, dangling=true.

      --no-trunc=false: Does not delete any output.

      -q and --quiet=false: Display only IDs.


      $ sudo docker images
      REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
      busybox             latest              e02e811dd08f        2 years ago         1.09MB



      Syntax: docker import URL|- [repository[:tag]]

      Function: Imports a .tar package that contains rootfs as an image. This parameter corresponds to the docker export command.

      Parameter description: none.


      Run the following command to generate a new image for busybox.tar exported using the docker export command:

      $ sudo docker import busybox.tar busybox:test
      $ sudo docker images
      REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
      busybox             test                a79d8ae12403        2 seconds ago       1.3MB



      Syntax: docker load [options]

      Function: Reloads an image from .tar package obtained by running the docker save command. This parameter corresponds to the docker save command.

      Parameter description:

      -i and --input="" can be used.


      $ sudo docker load -i busybox.tar
      Loaded image ID: sha256:e02e811dd08fd49e7f6032625495118e63f597eb150403d02e3238af1df240ba
      $ sudo docker images
      REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
      busybox             latest              e02e811dd08f        2 years ago         1.09MB


      Syntax: docker login [options] [server]

      Function: Logs in to an image server. If no server is specified, the system logs in to https://index.docker.io/v1/ by default.

      Parameter description:

      -e and --email="": Email address.

      -p and --password="": Password.

      -u and --username="": User name.


      $ sudo docker login


      Syntax: docker logout [server]

      Function: Logs out of an image server. If no server is specified, the system logs out of https://index.docker.io/v1/ by default.

      Parameter description: none.


      $ sudo docker logout


      Syntax: docker pull [options] name[:tag]

      Function: Pulls an image from an official or private registry.

      Parameter description:

      -a and --all-tags=false: Download all images in a registry. (A registry can be tagged with multiple tags. For example, a busybox registry may have multiple tags, such as busybox:14.04, busybox:13.10, busybox:latest. If -a is used, all busybox images with tags are pulled.)


      1. Run the following command to obtain the Nginx image from the official registry:

        $ sudo docker pull nginx
        Using default tag: latest
        latest: Pulling from official/nginx
        94ed0c431eb5: Pull complete
        9406c100a1c3: Pull complete
        aa74daafd50c: Pull complete
        Digest: sha256:788fa27763db6d69ad3444e8ba72f947df9e7e163bad7c1f5614f8fd27a311c3
        Status: Downloaded newer image for nginx:latest

        When an image is pulled, the system checks whether the dependent layer exists. If yes, the local layer is used.

      2. Pull an image from a private registry.

        Run the following command to pull the Fedora image from the private registry, for example, the address of the private registry is

        $ sudo docker pull


      Syntax: docker push name[:tag]

      Function: Pushes an image to the image registry.

      Parameter description: none.


      1. Run the following command to push an image to the private image registry at

      2. Label the image to be pushed. (The docker tag command is described in the following section.) In this example, the image to be pushed is busybox:sshd.

        $ sudo docker tag ubuntu:sshd
      3. Run the following command to push the tagged image to the private image registry:

        $ sudo docker push

        During the push, the system automatically checks whether the dependent layer exists in the image registry. If yes, the layer is skipped.


      Syntax: docker rmi [options] _image _[image...]

      Function: Deletes one or more images. If an image has multiple tags in the image library, only the untag operation is performed when the image is deleted. If the image has only one tag, the dependent layers are deleted in sequence.

      Parameter description:

      -f and --force=false: Forcibly delete an image.

      --no-prune=false: Does not delete parent images without tags.


      $ sudo docker rmi


      Syntax: docker save [options] _image _[image...]

      Function: Saves an image to a TAR package. The output is STDOUT by default.

      Parameter description:

      -o and --output="": Save an image to a file rather than STDOUT.


      $ sudo docker save -o nginx.tar nginx:latest
      $ ls

      Syntax: **docker search **options TERM

      Function: Searches for a specific image in the image registry.

      Parameter description:

      --automated=false: Displays the automatically built image.

      --no-trunc=false: Does not delete any output.

      -s and --stars=0: Display only images of a specified star level or higher.


      1. Run the following command to search for Nginx in the official image library:

        $ sudo docker search nginx
        NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
        nginx                             Official build of Nginx.                        11873               [OK]
        jwilder/nginx-proxy               Automated Nginx reverse proxy for docker con...   1645                                    [OK]
        richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable of...   739                                     [OK]
        linuxserver/nginx                 An Nginx container, brought to you by LinuxS...   74
        bitnami/nginx                     Bitnami nginx Docker Image                      70                                      [OK]
        tiangolo/nginx-rtmp               Docker image with Nginx using the nginx-rtmp...   51                                      [OK]


      2. Run the following command to search for busybox in the private image library. The address of the private image library must be added during the search.

        $ sudo docker search


      Syntax: docker tag [options] image[:tag] [registry host/][username/]name[:tag]

      Function: Tags an image to a registry.

      Parameter description:

      -f or --force=false: Forcibly replaces the original image when the same tag name exists.


      $ sudo docker tag busybox:latest busybox:test

      Bug Catching

      Buggy Content

      Bug Description

      Submit As Issue

      It's a little complicated....

      I'd like to ask someone.


      Just a small problem.

      I can fix it online!

      Bug Type
      Specifications and Common Mistakes

      ● Misspellings or punctuation mistakes;

      ● Incorrect links, empty cells, or wrong formats;

      ● Chinese characters in English context;

      ● Minor inconsistencies between the UI and descriptions;

      ● Low writing fluency that does not affect understanding;

      ● Incorrect version numbers, including software package names and version numbers on the UI.


      ● Incorrect or missing key steps;

      ● Missing prerequisites or precautions;

      ● Ambiguous figures, tables, or texts;

      ● Unclear logic, such as missing classifications, items, and steps.


      ● Technical principles, function descriptions, or specifications inconsistent with those of the software;

      ● Incorrect schematic or architecture diagrams;

      ● Incorrect commands or command parameters;

      ● Incorrect code;

      ● Commands inconsistent with the functions;

      ● Wrong screenshots.

      Risk Warnings

      ● Lack of risk warnings for operations that may damage the system or important data.

      Content Compliance

      ● Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions;

      ● Copyright infringement.

      How satisfied are you with this document

      Not satisfied at all
      Very satisfied
      Click to create an issue. An issue template will be automatically generated based on your feedback.
      Bug Catching
      编组 3备份