Can docker assembly use git branch url?

According to docs , the git url can be passed to the build command: enter image description here

But what happens if the git url should be the name of the branch? In other words, how can I do the equivalent of this:

git clone -b my-firefox-branch git @ github.com: creack / docker-firefox.git

+7
docker
source share
3 answers

Not yet. It can't.

Here is what I got:

$ docker build git@github.com :shawnzhu/docker-ruby.git#branch1 2014/12/04 08:19:04 Error trying to use git: exit status 128 (Cloning into '/var/folders/9q/bthxttfj2lq7jtz0b_f938gr0000gn/T/docker-build-git859493111'... fatal: remote error: is not a valid repository name Email support@github.com for help ) 

If you look at this docker CLI line of code, it will only make a recursive git clone against the given git repo url (not even --depth=1 ) when using docker build <git-repo-url> .

However, this can be an interesting docker enhancement (if people want it), since #<branch-name> and #<commit> are a popular syntax for the github URL accepted by many tools like npm and bower.

+3
source share

Start your URL with git:// (or https:// ) and just add the branch name after # .

I simply forked out OP repo and created a branch to confirm its operation (docker version 1.11.1):

 root@box :~# docker build git://github.com/michielbdejong/docker-firefox#michielbdejong-patch-1 Sending build context to Docker daemon 52.22 kB Step 1 : FROM ubuntu:12.04 12.04: Pulling from library/ubuntu 4edf76921243: Downloading [==========> ] 9.633 MB/44.3 MB ^ Croot@box :~# 

See https://docs.docker.com/engine/reference/commandline/build/ for complete documents.

+2
source share

Well, this works more or less depending on the versions

For latest versions: (docker-engine 1.5.0-0 ~ trusty and +)

 docker build https://github.com/rzr/iotjs.git#master docker build https://github.com/rzr/iotjs.git docker build github.com/rzr/iotjs.git 

For older: (docker.io 1.4-5ubuntu1 and -)

 docker build https://github.com/rzr/iotjs.git docker build git://github.com/rzr/iotjs.git docker build github.com/rzr/iotjs.git 

Perhaps this can be handled in a script helper, for example:

 curl -sL https://rawgit.com/rzr/iotjs/master/run.sh | bash -x - 
0
source share

All Articles