在Github仓库的非主分支上构建镜像是否可行?
例如,我有一个名为//github.com/myAccount/docker-myImage
的仓库,并且有一个development
分支,我想要用它来构建我的镜像。不幸的是,下面的命令似乎只允许从master
分支构建:
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
这样的吗?
git clone -b branch something
命令。其中,clone
表示克隆代码库,-b
表示指定分支,branch
为分支名称,something
为要克隆的代码库地址。 - Wolfgang