Docker: how to build an image from a non-master branch on Github repository

Is it possible to build an image from a non-master branch on a Github repository?

For example, I have the repository // with a branch development that I would like to use for my image. Unfortunately, the following command only seems to allow building from the master branch:

  • Accessing docker host from (jenkins) docker container
  • Not getting Docker to run from within Jenkins
  • How to run google chrome headless in docker?
  • Storing submodules for micro services, but still using forks
  • Changing the user's uid in a pre-build docker container (jenkins)
  • Where should environment-specific values be saved in a Laravel 5 application?
  • docker build -t myAccount/myImage git://

    Here is the relevant documentation from 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
                  Note: You can set an arbitrary Git repository via the git:// schema.

    Perhaps there is an alternative, like docker build -t myAccount/myImage git://

  • How do I transfer a git repo to my other computer?
  • Protecting files in git repository
  • What is the difference between git push and git pull?
  • Exclude .svn folders within git
  • Git diff -w ignore whitespace only at start & end of lines
  • Git on Windows: Where are my files?
  • 3 Solutions collect form web for “Docker: how to build an image from a non-master branch on Github repository”

    docker build -t myAccount/myImage

    See docker build command reference for more options.

    The doc that you quoted itself mentions how you can specify the branch:

    Change tree/master to the branch you want and see.

    I proposed this question on #docker at the Freenode IRC and the user scollier contacted me and he said that he’ll get back to me about this issue. I believe he is involved with the Docker documentation that I mentioned in my questions. In the meantime, I found a workaround by adding the following to my Dockerfile:

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

    This solution seems to solve all my needs. Thanks for the support!

    Git Baby is a git and github fan, let's start git clone.