2014-12-29 36 views
5

是否可以從Github存儲庫上的非主分支構建圖像?Docker:如何從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

回答

3

的文件,讓您引述本身提到了如何指定分支:

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

更改tree/master你想要看到的分支機構。

+0

其實,這是行不通的。例如,當我執行上述命令時,出現錯誤:'repository 'https://github.com/fedora-cloud/Fedora-Dockerfiles/tree/master/apache/' not found' – modulitos

1

我在Freenode IRC的#docker上提出這個問題,用戶scollier與我聯繫,他說他會回覆我這個問題。我相信他參與了我在問題中提到的Docker文檔。在此期間,我發現了一個解決方法通過將下面我Dockerfile

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

該解決方案似乎解決了我所有的需要。感謝您的支持!

+3

'RUN git克隆-b分支東西' – Wolfgang