Options:
--add-host list Add a custom host-to-IP mapping (host:ip)--build-arg list Set build-time variables--cache-from stringSlice Images to consider as cache sources--cgroup-parent string Optional parent cgroup for the container--compress Compress the build context using gzip --cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota
-c, --cpu-shares int CPU shares (relative weight)
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
--disable-content-trust Skip image verification (default true)
-f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile')
--force-rm Always remove intermediate containers
--help Print usage
--isolation string Container isolation technology
--label list Set metadata for an image
-m, --memory bytes Memory limit
--memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--network string Set the networking mode for the RUN instructions during build (default "default")
--no-cache Do not use cache when building the image
--pull Always attempt to pull a newer version of the image
-q, --quiet Suppress the build output and print image> --rm Remove intermediate containers after a successful build (default true)
--security-opt stringSlice Security options
--shm-size bytes > -t, --tag list Name and optionally a tag in the 'name:tag' format
--target string Set the target build stage to build.
--ulimit ulimit Ulimit options (default [])
使用这个命令来搭配Dockerfile 创建一个image
PATH or URL 在这2项中的文件被当作资源上下文. 创建image过程中,所有的文件都可能会被标记,比如说执行 ADD (link is external) 项. 当一个Dockerfile只有 URL STDIN (docker build - < Dockerfile), 那么就没有上下文了.
如果 URL 中指定了一个git repo,那么这个git repo也会被使用。 这个git repo会被当作子目录 (git clone -recursive). A fresh git clone occurs in a temporary directory on your local host, and then this is sent to the Docker daemon as the context. 反正如果使用git你必须处理好git的凭证和假如需要的VPN设置.
.dockerignore 在 PATH 项的根目录,这提供一种指定忽略的方式. 符合忽略规则的文件或目录将被忽略。
从官网文档来看https://docs.docker.com/engine/reference/builder/#usage
首先建议一个新的目录,这个文件下面是你需要创建这个镜像时所用到的文件,还有一个叫“Dockerfile”的文件,而这个文件就是我们构建镜像文档文。我们要写指令就是放在这个文件里。
我们可以用-f 参数来指定其它地方的dockerfile