2014-11-05 55 views
17

在官方的文档,我们可以看到:如何从GitHub资源库建设搬运工图像

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

这只是工作没什么问题。 docker-firefox是一个存储库,在根目录中有Dockerfile
然后我想打造专业化Redis的图像和详细的版本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 
) 

我得到上述错误。从github repos构建docker镜像的格式是什么?

回答

3

您指定为repo URL的东西不是有效的git存储库。你会得到错误时,你会尝试

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

有效网址这个回购协议github.com/docker-library/redis。所以,你可能想尝试以下操作:

docker build github.com/docker-library/redis

但是这不会太工作。要从github构建,docker需要Dockerfile在repository root中,但是,这个repo不提供这个。所以,我建议,你只需要克隆这个repo并使用本地Dockerfile构建镜像。

+1

其实'泊坞窗共建https://开头raw.githubusercontent.com /搬运工库/ Redis的/主/ 2.8.10/Dockerfile'工作,但不喜欢[官方示例](http://docs.docker.com/v1.1/reference/commandline/cli/#build)。感谢您的回答。 – seanlook 2014-11-05 12:58:09

12

docker build uri#ref:dir

GIT中的URL接受上下文配置在它们的片段部分, 用冒号隔开。第一部分代表Git将检查出的参考,这可以是分支,标记或提交 SHA。第二部分表示存储库 中的一个子目录,它将用作构建上下文。

例如,运行此命令要使用一个称为码头工人目录中的 分支容器:

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

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

0

人们可以使用下面的示例,其设置了一个CentOS 7容器测试ORC文件格式。确保逃离#标志:

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