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

标签 git docker github branch

是否可以从 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

最佳答案

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

docker build command reference更多选择。

关于git - Docker:如何从 Github 存储库上的非主分支构建镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27683927/

相关文章:

git - 如何将 git repo 添加为自身的子模块? (或 : How to generate GitHub Pages programmatically? )

Git:使用共享本地存储进行克隆(使用硬链接(hard link))

git - GitHub 附带的 Git 版本没有别名功能吗?

github - Github 语言统计中未排除的路径

git branch -d <branchname> 抛出错误 : branch <branchname> not found

git - 有没有办法使用 VSCode 通过远程 SSH 运行 "git difftool"?

amazon-web-services - 从用户数据重启ecs-agent

Docker 机器可以 ssh 但不能 scp

docker-compose 没有设置环境变量

ruby-on-rails - 应用程序错误-heroku 检查日志?