How to build docker image from github repository

One can use the following example which sets up a Centos 7 container for testing ORC file format. Make sure to escape the # sign:

$ docker build https://github.com/apache/orc.git\#:docker/centos7 -t orc-centos7


docker build url#ref:dir

Git URLs accept context configuration in their fragment section, separated by a colon :. The first part represents the reference that Git will check out, this can be either a branch, a tag, or a commit SHA. The second part represents a subdirectory inside the repository that will be used as a build context.

For example, run this command to use a directory called docker in the branch container:

docker build https://github.com/docker/rootfs.git#container:docker

https://docs.docker.com/engine/reference/commandline/build/


The thing you specified as repo URL is not a valid git repository. You will get error when you will try

git clone github.com/docker-library/redis/tree/99c172e82ed81af441e13dd48dda2729e19493bc/2.8.10

Valid URL for this repo is github.com/docker-library/redis. So you may want to try following:

docker build github.com/docker-library/redis

But this will not work too. To build from github, docker requires Dockerfile in repository root, howerer, this repo doesn't provide this one. So, I suggest, you only have to clone this repo and build image using local Dockerfile.

Tags:

Docker

Redis