无法从 github 存储库分支构建 docker 图像

Can't build docker image from github repository branch

我有一个私人 GitHub 存储库,其中包含 2 个分支:masterstage。 存储库包含 Dockerfile 和构建容器映像所需的其他文件。 根据 documentation 我可以在调用 docker 构建命令时指定分支。

不过,我可以运行:

sudo docker build -t="superimage" https://github.com/organization/repo.git

在此之后,系统要求我提供 GitHub 登录名和密码。

但是当我尝试 运行:

https://github.com/organization/repo.git#stage

我得到:

Error: Got HTTP status code >= 400: 404 Not Found

我做错了什么?

根据变更日志 (https://github.com/docker/docker/blob/master/CHANGELOG.md#170-2015-06-16),特定 git 分支的构建似乎是 1.7 中引入的一项功能。您需要升级到 1.7+ 才能获得此功能。