centos6.5安装Docker
前提条件
Docker运行对内核要求比较高,因此一般建议直接在Ubuntu这样的平台运行。但作为一个容器标准,Docker也是支持其他如CentOS, Mac OS X, Windows等平台。目前Docker支持以下版本CentOS:
- CentOS 7(64位)
- CentOS 6.5(64位)及以后
在运行CentOS 6.5及以后版本时,需要内核版本>=2.6.32-431,因为这些内核包含了运行Docker的一些特定修改。
$ uname -r
2.6.32-431.17.1.el6.x86_64
Device Mapper
Docker默认使用AUFS作为存储驱动,但是AUFS并没有被包括在Linux的主线内核中。CentOS中可以使用Device Mapper作为存储驱动,这是在2.6.9内核版本引入的新功能。我们需要先确认是否启用该功能:
$ ls -l /sys/class/misc/device-mapper
lrwxrwxrwx 1 root root 0 May 1 20:55 /sys/class/misc/device-mapper -> ../../devices/virtual/misc/device-mapper
如果没有检测到Device Mapper,需要安装device-mapper软件包:
$ yum install -y device-mapper
然后重新加载dm_mod内核模块:
$ modprobe dm_mod
对于centos 6.5 需要先安装源
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
$ yum install docker-io -y
提示无法安装
查阅资料,yum install docker-io,这句话是用源安装docker,可是源一般是国外源,用这个命令因为GFW被墙,根本安装不了。开源中国Docker更新记录
Ubuntu/Debian: curl -sSL https://get.docker.com | sh
Linux 64bit binary: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1
Darwin/OSX 64bit client binary: https://get.docker.com/builds/Darwin/x86_64/docker-1.7.1
Darwin/OSX 32bit client binary: https://get.docker.com/builds/Darwin/i386/docker-1.7.1
Linux 64bit tgz: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1.tgz
Windows 64bit client binary: https://get.docker.com/builds/Windows/x86_64/docker-1.7.1.exe
Windows 32bit client binary: https://get.docker.com/builds/Windows/i386/docker-1.7.1.exe
Centos 6/RHEL 6: https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm
Centos 7/RHEL 7: https://get.docker.com/rpm/1.7.1/centos-7/RPMS/x86_64/docker-engine-1.7.1-1.el7.centos.x86_64.rpm
Fedora 20: https://get.docker.com/rpm/1.7.1/fedora-20/RPMS/x86_64/docker-engine-1.7.1-1.fc20.x86_64.rpm
Fedora 21: https://get.docker.com/rpm/1.7.1/fedora-21/RPMS/x86_64/docker-engine-1.7.1-1.fc21.x86_64.rpm
Fedora 22: https://get.docker.com/rpm/1.7.1/fedora-22/RPMS/x86_64/docker-engine-1.7.1-1.fc22.x86_64.rpm
使用Centos 6/RHEL 6,开始安装
yum install https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm
启动Docker
service docker start
查看Docker信息
docker info
设置开机启动
chkconfig docker on