为什么Docker构建没有-f参数?

时间:2015-07-12 15:05:31

标签: docker dockerfile

的输出
sudo docker build --help

--force-rm=false     Always remove intermediate containers, even after unsuccessful builds
--no-cache=false     Do not use cache when building the image
-q, --quiet=false    Suppress the verbose output generated by the containers
--rm=true            Remove intermediate containers after a successful build
-t, --tag=""         Repository name (and optionally a tag) to be applied to the resulting image in case of success

在线文档https://docs.docker.com/reference/commandline/build/

中有更多参数

例如参数-f指定Dockerfile的文件名

1 个答案:

答案 0 :(得分:2)

您应该检查您的docker版本,然后需要升级它。根据docker的changelogdocker build -f参数已在version 1.5.0中实现

我也在自己的机器上用docker版本1.6.2进行了测试

$docker --version
Docker version 1.6.2, build 7c8fca2

$docker build --help

Usage: docker build [OPTIONS] PATH | URL | -

Build a new image from the source code at PATH

  -c, --cpu-shares=0    CPU shares (relative weight)
  --cpuset-cpus=        CPUs in which to allow execution (0-3, 0,1)
  -f, --file=           Name of the Dockerfile (Default is 'PATH/Dockerfile')
  --force-rm=false      Always remove intermediate containers
  --help=false          Print usage
  -m, --memory=         Memory limit
  --memory-swap=        Total memory (memory + swap), '-1' to disable swap
  --no-cache=false      Do not use cache when building the image
  --pull=false          Always attempt to pull a newer version of the image
  -q, --quiet=false     Suppress the verbose output generated by the containers
  --rm=true             Remove intermediate containers after a successful build
  -t, --tag=            Repository name (and optionally a tag) for the image

您可以看到它支持-f参数。