以下版本的CentOS 支持 Docker :
* [_CentOS 7 (64-bit)_](https://github.com/widuu/chinese_docker/blob/master/installation/centos.md#installing-docker-centos-7)
* [_CentOS 6.5 (64-bit)_](https://github.com/widuu/chinese_docker/blob/master/installation/centos.md#installing-docker-centos-6.5)?or later
該指南可能會適用于其它的 EL6/EL7 的 Linux 發行版,譬如 Scientific Linux 。但是我們沒有做過任何測試。
請注意,由于 Docker 的局限性,Docker 只能運行在64位的系統中。
## 內核支持
目前的 CentOS 項目,僅發行版本中的內核支持 Docker。如果你打算在非發行版本的內核上運行 Docker ,內核的改動可能會導致出錯。
Docker 運行在?[CentOS-6.5](https://github.com/widuu/chinese_docker/blob/master/installation/www.centos.org)?或更高的版本的 CentOS 上,需要內核版本是 2.6.32-431 或者更高版本 ,因為這是允許它運行的指定內核補丁版本。
## 安裝 - CentOS-7
Docker 軟件包已經包含在默認的 CentOS-Extras 軟件源里,安裝命令如下:
~~~
$ sudo yum install docker
~~~
開始運行?[Docker daemon](https://github.com/widuu/chinese_docker/blob/master/installation/centos.md#starting-the-docker-daemon)。
### FirewallD
CentOS-7 中介紹了 firewalld,firewall的底層是使用iptables進行數據過濾,建立在iptables之上,這可能會與 Docker 產生沖突。
當?`firewalld`?啟動或者重啟的時候,將會從 iptables 中移除?`DOCKER`?的規則,從而影響了 Docker 的正常工作。
當你使用的是 Systemd 的時候,?`firewalld`?會在 Docker 之前啟動,但是如果你在 Docker 啟動之后再啟動 或者重啟`firewalld`?,你就需要重啟 Docker 進程了。
## 安裝 Docker - CentOS-6.5
在 CentOS-6.5 中,Docker 包含在?[Extra Packages for Enterprise Linux (EPEL)](https://fedoraproject.org/wiki/EPEL)?提供的鏡像源中,該組織致力于為 RHEL 發行版創建和維護更多可用的軟件包。
首先,你需要安裝 EPEL 鏡像源,請查看?[EPEL installation instructions](https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F).
在 CentOS-6 中,一個系統自帶的可執行的應用程序與 docker 包名字發生沖突,所以我們重新命名 docker 的RPM包名字為?`docker-io`?。
CentOS-6 中 安裝?`docker-io`?之前需要先卸載?`docker`?包。
~~~
$ sudo yum -y remove docker
~~~
下一步,安裝?`docker-io`?包來為我們的主機安裝 Docker。
~~~
$ sudo yum install docker-io
~~~
開始運行?[Docker daemon](https://github.com/widuu/chinese_docker/blob/master/installation/centos.md#starting-the-docker-daemon)。
## 手動安裝最新版本的 Docker
當你使用推薦方法來安裝 Docker 的時候,上述的 Docker 包可能不是最新發行版本。 如果你想安裝最新版本,[你可以直接安裝二進制包](https://github.com/widuu/chinese_docker/blob/master/installation/binaries.md)
當你使用二進制安裝時,你可能想將 Docker 集成到 Systemd 的系統服務中。為了實現至一點,你需要從github中下載[service and socket](https://github.com/docker/docker/tree/master/contrib/init/systemd)兩個文件,然后安裝到?`/etc/systemd/system`?中。
Please continue with the?[Starting the Docker daemon](https://github.com/widuu/chinese_docker/blob/master/installation/centos.md#starting-the-docker-daemon).
## Starting the Docker daemon
當 Docker 安裝完成之后,你需要啟動 docker 進程。
~~~
$ sudo service docker start
~~~
如果我們希望 Docker 默認開機啟動,如下操作:
~~~
$ sudo chkconfig docker on
~~~
現在,我們來驗證 Docker 是否正常工作。第一步,我們需要下載最新的?`centos`?鏡像。
~~~
$ sudo docker pull centos
~~~
下一步,我們運行下邊的命令來查看鏡像,確認鏡像是否存在:
~~~
$ sudo docker images centos
~~~
這將會輸出如下的信息:
~~~
$ sudo docker images centos
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 0b443ba03958 2 hours ago 297.6 MB
~~~
運行簡單的腳本來測試鏡像:
~~~
$ sudo docker run -i -t centos /bin/bash
~~~
如果正常運行,你將會獲得一個簡單的 bash 提示,輸入?`exit`?來退出。
## 自定義進程選項
如果你想要添加一個 HTTP 代理,為 Docker 運行文件設置不同的目錄或分區,又或者定制一些其它的功能,請閱讀我們的系統文章,了解[如何定制 Docker 進程](https://github.com/widuu/chinese_docker/blob/master/articles/systemd.md)
## Dockerfiles
CentOS 項目為開發者提供了大量的的示例鏡像,作為開發模板或者學習 Docker 的實例。你可以在這里找到這些示例:
[https://github.com/CentOS/CentOS-Dockerfiles](https://github.com/CentOS/CentOS-Dockerfiles)
好!現在你可以去查看[用戶指南](https://github.com/widuu/chinese_docker/blob/master/userguide/README.md),或者創建你自己的鏡像了。
## 發現問題?
如果有關于在 CentOS 上的 Docker 問題,請直接在這里提交:[CentOS Bug Tracker](http://bugs.centos.org/).
- 關于Docker
- 鏡像簡介
- 安裝篇
- Mac OS X
- Ubuntu
- Red Hat Enterprise Linux
- CentOS
- Debain
- Gentoo
- Google Cloud Platform
- Rackspace Cloud
- Amazon EC2
- IBM Softlayer
- Arch Linux
- FrugalWare
- Fedora
- openSUSE
- CRUX Linux
- Microsoft Windows
- Binaries
- 用戶指南
- 使用Docker Hub
- 在Docker中運行應用
- 使用容器
- 使用docker鏡像
- 連接容器
- 管理容器數據
- 使用Docker Hub
- Docker Hub
- 賬戶
- 存儲庫
- 自動構建
- 官方案例
- Docker中運行MongoDB
- Docker中運行Redis服務
- Docker中運行PostgreSQL
- Docker中運行Riak服務
- Docker中運行SSH進程服務
- Docker中運行CouchDB服務
- Docker中運行Apt-Cacher-ng服務