According to the docs, a git url can be passed to a build command:
But what happens if the git url needs to be a branch name? In other words, how do I do the equivalent of this:
git clone -b my-firefox-branch [email protected]:creack/docker-firefox.git
Start your URL with git://
(or https://
) and simply append the branch name after #
.
I just forked the OP's repo and created a branch to confirm it works (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 full docs.
So far, No. it can't.
Here's what I got:
$ docker build [email protected]: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 [email protected] for help
)
If you take a look at this line of docker CLI code, it only do recursive git clone against given URL of a git repo (even no --depth=1
) when using docker build <git-repo-url>
.
However, it could be an interesting improvement to docker (if people want it) since #<branch-name>
and #<commit>
are popular syntax to github URL adopted by lots of tools like npm and bower.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With