Skip to content

Commit

Permalink
修正usingdocker.md的连接错误,添加文章:baseimages
Browse files Browse the repository at this point in the history
  • Loading branch information
Gogs committed Aug 15, 2014
1 parent 0f54d2d commit 0f0f5a9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
44 changes: 44 additions & 0 deletions articles/baseimages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 创建一个基本镜像
==================


你想创建你自己的[基础镜像](../terms/image.md)?很好!

具体的过程会严重依赖于你想打包的Linux发行版。我们有下面一些例子供你参考。
同时,我们鼓励你通过提交推送请求来贡献你的新镜像。


### 使用 tar 来创建一个完整的镜像

通常,你要先运行一个可工作的发行版的机器,来打包一个基础镜像。虽然有一些
工具不是必需的,比如 Debian 的 Deboostrap,但是你还是可以用它来生成 Ubuntu
镜像。

下面的例子尽可能简单地创建一个 Ubuntu 基础镜像:

$ sudo debootstrap raring raring > /dev/null
$ sudo tar -C raring -c . | sudo docker import - raring
a29c15f1bf7a
$ sudo docker run raring cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.04
DISTRIB_CODENAME=raring
DISTRIB_DESCRIPTION="Ubuntu 13.04"

在 Docker 的 GitHub 上,有更多的创建基础镜像的脚本示例:

- [BusyBox](https://github.com/dotcloud/docker/blob/master/contrib/mkimage-busybox.sh)
- CentOS / Scientific Linux CERN (SLC) [on Debian/Ubuntu](https://github.com/dotcloud/docker/blob/master/contrib/mkimage-rinse.sh) or on [CentOS/RHEL/SLC/etc](https://github.com/dotcloud/docker/blob/master/contrib/mkimage-yum.sh).
- [Debian / Ubuntu](https://github.com/dotcloud/docker/blob/master/contrib/mkimage-debootstrap.sh)


### 使用 scratch 创建简单的基础镜像

在 Docker 的注册中,有一个使用空的 tar 文件创建的特殊的版本库,叫 scratch :

$ tar cv --files-from /dev/null | docker import - scratch

你可以用 *** docker pull *** 把它拉取下来。然后你就可以基于它来做新的最小
的容器了:

上面的 Dockerfile 来自外部的一个最小镜像:[tianon/true](https://github.com/tianon/dockerfiles/tree/master/true)
34 changes: 34 additions & 0 deletions terms/image.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 镜像
======

### 介绍

![基础镜像](images/docker-filesystems-debian.png)

在 Docker 的术语里,一个只读层被称为镜像,一个镜像是永久不会变的。

由于 Docker 使用一个统一文件系统,Docker 进程认为整个文件系统是以读写方式挂载的。
但是所有的变更都发生顶层的可写层,而下层的原始的只读镜像文件并未变化。由于镜像不
可写,所以镜像是无状态的。

![镜像可写层](images/docker-filesystems-debianrw.png)


### 父镜像

![镜像层次](images/docker-filesystems-multilayer.png)

每一个镜像都可能依赖于由一个或多个下层的组成的另一个镜像。我们有时说,下层那个
镜像是上层镜像的父镜像。


### 基础镜像

一个没有任何父镜像的镜像,谓之基础镜像。


### 镜像ID

所有镜像都是通过一个 64 位十六进制字符串 (内部是一个 256 bit 的值)来标识的。
为简化使用,前 12 个字符可以组成一个短ID,可以在命令行中使用。短ID还是有一定的
碰撞机率,所以服务器总是返回长ID。
Binary file added terms/images/docker-filesystems-debian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added terms/images/docker-filesystems-debianrw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added terms/images/docker-filesystems-multilayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion userguide/usingdocker.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,4 @@ Docker可以配置绑定网络端口。在最后一个例子中`-P`标示,是`

直到现在我们使用镜像,我们从Docker Hub下载,现在我们建设和分享我们的镜像。

阅读[使用镜像](userguide/dockerimages.md)
阅读[使用镜像](dockerimages.md)

0 comments on commit 0f0f5a9

Please sign in to comment.