Docker:如何从Github存储库上的非主分支构建映像

mod*_*tos 12 git branch github docker

是否可以从Github存储库上的非主分支构建映像?

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

docker build -t myAccount/myImage git://github.com/myAccount/docker-myImage
Run Code Online (Sandbox Code Playgroud)

以下是相关文档man docker build:

docker build github.com/scollier/Fedora-Dockerfiles/tree/master/apache
Run Code Online (Sandbox Code Playgroud)

也许有另一种选择,比如docker build -t myAccount/myImage git://github.com/myAccount/docker-myImage:development

mic*_*ong 11

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

有关更多选项,请参阅docker build命令参考.


mod*_*tos 6

我在 Freenode IRC 上提出了这个问题#docker,用户scollier联系了我,他说他会就这个问题回复我。我相信他参与了我在问题中提到的 Docker 文档。与此同时,我通过将以下内容添加到我的 中找到了解决方法Dockerfile

RUN git clone something && cd something && git checkout branch
Run Code Online (Sandbox Code Playgroud)

这个解决方案似乎可以解决我的所有需求。感谢您的支持!

  • `运行 git clone -b 分支某事` (4认同)