为什么 Docker build 没有 -f 参数?

Why Docker build do not have -f parameter?

来自

的输出
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的文件名

你应该检查你的docker版本,你需要升级它。根据 docker 的 changelog, docker build with -f parameter is implemented in 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 参数。