1. 程式人生 > >【docker】02、docker安裝

【docker】02、docker安裝

docker



一、在CentOS上安裝Docker

以下版本的CentOS 支持 Docker :

  • CentOS 7 (64-bit) # CentOS 從 7 開始,和 RHEL 7 一樣都只支持 64 位架構。

  • CentOS 6.5 (64-bit) or later

請註意,由於 Docker 的局限性,Docker 只能運行在64位的系統中。

內核支持

Docker 運行在 CentOS-6.5 或更高的版本的 CentOS 上,需要內核版本是 2.6.32-431 或者更高版本 ,因為這是允許它運行的指定內核補丁版本。

1、安裝 - CentOS-7

Docker 軟件包已經包含在默認的 CentOS-Extras 軟件源裏,安裝命令如下:

    $ yum install docker

FirewallD

CentOS-7 中firewall的底層是使用iptables進行數據過濾,建立在iptables之上,這可能會與 Docker 產生沖突。當 firewalld 啟動或者重啟的時候,將會從 iptables 中移除 DOCKER 的規則,從而影響了 Docker 的正常工作。

當你使用的是 Systemd 的時候, firewalld 會在 Docker 之前啟動,但是如果你在 Docker 啟動之後再啟動 或者重啟 firewalld ,你就需要重啟 Docker 進程了。


2、安裝 Docker - CentOS-6.5

在 CentOS-6.5 中,Docker 包含在 Extra Packages for Enterprise Linux (EPEL) 提供的鏡像源中,該組織致力於為 RHEL 發行版創建和維護更多可用的軟件包。

要求內核版本為3.10.0以上,由於RHEL 6和CentOS 6的內核版本為2.6,因此必須要先升級內核;所以一般都直接使用CentOS7。


在 CentOS-6 中,一個系統自帶的可執行的應用程序與 docker 包名字發生沖突,所以我們重新命名 docker 的RPM包名字為 docker-io

[[email protected]
/* */ ~]# yum list|grep docker docker-io.x86_64 1.7.1-2.el6 @epel docker.x86_64 1.5-5.el6 epel docker-io-devel.x86_64 1.7.1-2.el6 epel docker-io-fish-completion.x86_64 1.7.1-2.el6 epel docker-io-logrotate.x86_64 1.7.1-2.el6 epel docker-io-vim.x86_64 1.7.1-2.el6 epel docker-io-zsh-completion.x86_64 1.7.1-2.el6 epel fedora-dockerfiles.x86_64 0-0.12.gitf6cd84c.el6 epel golang-github-docker-libcontainer.x86_64 1.1.0-10.gitdb65c35.el6 epel golang-github-docker-libcontainer-devel.x86_64 golang-github-docker-libtrust-devel.noarch 0-0.4.git6b78349.el6 epel golang-github-docker-libtrust-unit-test.x86_64 golang-github-docker-spdystream-devel.noarch golang-github-docker-spdystream-unit-test.x86_64 golang-github-fsouza-go-dockerclient-devel.noarch golang-github-fsouza-go-dockerclient-unit-test.x86_64 python-docker-py.x86_64 0.7.0-1.el6 epel python-docker-registry-core.noarch 2.0.1-2.el6 epel python-dockerfile-parse.noarch 0.0.5-1.el6 epel


CentOS-6 中 安裝 docker-io 之前需要先卸載 docker 包:

    $ yum -y remove docker

下一步,安裝 docker-io 包來為我們的主機安裝 Docker:

    $  yum install docker-io

3、手動安裝最新版本的 Docker

上述的 Docker 包可能不是最新發行版本。 如果你想安裝最新版本

可以以不同的方式,安裝多克爾根據您的需要:

  • 使用docker 官方的yum源(常用)


  • 下載源碼包編譯安裝

Get Docker CE on CentOS

You can install Docker CE on CentOS in just three steps.

Enterprise customers can also installDocker EE for CentOS.

Prerequisites 先解決條件

Docker CE is supported on CentOS 7.3 64-bit.

1. Set up the repository

Set up the Docker CE repository on CentOS:

sudo yum install -y yum-utils

sudo yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo

sudo yum makecache fast

2. Get Docker CE

Install the latest version of Docker CE on CentOS:

sudo yum -y install docker-ce

Start Docker:

sudo systemctl start docker

3. Test your Docker CE installation

Test your installation:

sudo docker run hello-world

Next steps

These installation instructions work for standard installations of Docker CE. For more details or alternative installation procedures, including how to installedge builds, seeGet Docker for CentOS.

  • Optional post-installation steps

  • Docker User Guide


Dockerfiles

CentOS 項目為開發者提供了大量的的示例鏡像,作為開發模板或者學習 Docker 的實例。你可以在這裏找到這些示例:

https://github.com/CentOS/CentOS-Dockerfiles



【docker】02、docker安裝