首页 > 代码库 > 【docker】02、docker安装

【docker】02、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

[root@Node2 ~]# 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安装