Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build docker image from github repository

Tags:

docker

redis

In official docs we can see:

# docker build github.com/creack/docker-firefox 

It just works fine to me. docker-firefox is a repository and has Dockerfile within root dir.
Then I want to buid redis image and exact version 2.8.10 :

# docker build github.com/docker-library/redis/tree/99c172e82ed81af441e13dd48dda2729e19493bc/2.8.10 2014/11/05 16:20:32 Error trying to use git: exit status 128 (Initialized empty Git repository in /tmp/docker-build-git067001920/.git/ error: The requested URL returned error: 403 while accessing https://github.com/docker-library/redis/tree/99c172e82ed81af441e13dd48dda2729e19493bc/2.8.10/info/refs  fatal: HTTP request failed ) 

I got error above. What's the right format with build docker image from github repos?

like image 509
seanlook Avatar asked Nov 05 '14 08:11

seanlook


People also ask

Can GitHub host Docker images?

You can publish Docker images to a registry, such as Docker Hub or GitHub Packages, as part of your continuous integration (CI) workflow.


2 Answers

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/

like image 196
rofrol Avatar answered Sep 20 '22 16:09

rofrol


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.

like image 32
Viacheslav Kovalev Avatar answered Sep 20 '22 16:09

Viacheslav Kovalev