Docker:如何从Github存储库上的非主分支构build一个图像

是否有可能从Github存储库上的非主分支构build图像?

例如,我有一个分支development的存储库//github.com/myAccount/docker-myImage ,我想用于我的图像。 不幸的是,下面的命令似乎只允许从master分支构build:

 docker build -t myAccount/myImage git://github.com/myAccount/docker-myImage 

以下是man docker build的相关文档:

 Building an image using a URL This will clone the specified Github repository from the URL and use it as context. The Dockerfile at the root of the repository is used as Dockerfile. This only works if the Github repository is a dedicated repository. docker build github.com/scollier/Fedora-Dockerfiles/tree/master/apache Note: You can set an arbitrary Git repository via the git:// schema. 

也许有一个替代,像docker build -t myAccount/myImage git://github.com/myAccount/docker-myImage:development

docker build -t myAccount/myImage https://github.com/myAccount/docker-myImage.git#development

请参阅docker build命令参考以获取更多选项。

您引用的文档中提到了如何指定分支:

 github.com/scollier/Fedora-Dockerfiles/tree/master/apache 

tree/master更改为您想要查看的分支。

我在Freenode IRC的#docker上提出了这个问题,用户scollier联系了我,他说他会回到我这个问题。 我相信他参与了我在问题中提到的Docker文档。 在此期间,我通过将下列内容添加到我的Dockerfilefind了一个解决方法:

 RUN git clone something && git cd something && git checkout branch 

这个解决scheme似乎解决了我所有的需求。 感谢您的支持!