Detailed explanation of Docker build command

  • buildDockerfileThe command is used to create an image using

  • grammar:

    $ docker build [OPTIONS] PATH | URL | -
    
  • OPTIONSillustrate

    # 可通过帮助命令查看
    $ docker build --help
    
    • --build-arg=[]: Set the variable when the image is created
    • --cpu-shares: set cpuusage weight
    • --cpu-period: limit CPU, CFScycle
    • --cpu-quota: limit CPU, CFSquota
    • --cpuset-cpus: designated to useCPU id
    • --cpuset-mems: designated to use内存 id
    • --disable-content-trust: Ignore validation, enabled by default
    • -fDockerfile: specifies the path to use
    • --force-rm: Delete intermediate containers during mirroring
    • --isolation: Use container isolation technology
    • --label=[]: Set the metadata used by the image
    • -m: set the maximum memory
    • --memory-swap: SwapThe maximum value of setting is memory + swap, "-1" means no limitswap
    • --no-cache: The process of creating the image does not use the cache
    • --pull: try to update the new version of the image
    • --quiet, -q: Quiet mode, only output after success镜像 ID
    • --rm: Delete the intermediate container after successfully setting the image
    • --shm-size: set /dev/shmthe size of the , the default value is64M
    • --ulimit: Ulimitconfiguration
    • --squash: DockerfileCompress all operations in to one layer
    • --tag, -t: The name and label of the image, usually name:tagor nameThe format can set multiple labels for an image in one build
    • --network: default defaultSets the network mode of the RUN instruction during build
  • Extended case

    # -t 给镜像加一个 Tag
    # ImageName 给镜像起的名称
    # TagName 给镜像的Tag名
    # dir Dockerfile所在目录
    # $ docker build -t ImageName:TagName dir
    
    # test-redis:镜像名
    # v1.1:tag 标签
    # .:表示当前目录,即 Dockerfile 所在目录
    $ docker build -t test-redis:v1.1 .
    

Guess you like

Origin blog.csdn.net/zz00008888/article/details/132060704