如何从github仓库构建docker镜像 [英] How to build docker image from github repository

查看:688
本文介绍了如何从github仓库构建docker镜像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在官方文档中我们可以看到:

In official docs we can see:

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

对我来说很好。 docker-firefox 是一个存储库,并且在根目录中有 Dockerfile

然后我要buid redis映像和确切版本2.8.10:

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?

推荐答案

docker build uri#ref:dir是什么格式?


Git URL在其片段部分接受上下文配置,
用冒号分隔:。第一部分代表
Git将检出的引用,它可以是分支,标签或提交
SHA。第二部分表示存储库
中的一个子目录,该子目录将用作构建上下文。

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.

例如,运行此命令以使用一个名为docker的目录,
分支容器:

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/

这篇关于如何从github仓库构建docker镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆