CentOS6/7 docker安装
官方网站:
环境:
CentOS6.5/7.1
docker-engine-1.11.2
一.docker官方yum源
cat >/etc/yum.repos.d/docker.repo <<'HERE'
[dockerrepo]
name=Docker
Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
HERE
或直接使用EPEL源
CentOS6:http://ftp.sjtu.edu.cn/fedora/epel/6/x86_64/
CentOS7:http://ftp.sjtu.edu.cn/fedora/epel/7/x86_64/
或者使用国内加速源(daocloud)安装
curl -sSL https://get.daocloud.io/docker | sh
二.安装docker
yum -y install docker-engine
提示:可能早期的包名叫docker-io(CentOS6),docker(CentOS7),同时docker-engine依赖libdevmapper.so.1.02,所以也需要CentOS官方base源
三.启动docker
service docker start
开机自启动
chkconfig docker on #CentOS6
systemctl enable docker #CentOS7
注意:CentOS6.5启动docker(docker -d)报错
INFO[0000] +job serveapi(unix:///var/run/docker.sock)
INFO[0000] WARNING: You are running linux kernel version
2.6.32-431.el6.x86_64, which might be unstable running
docker.
Please upgrade your kernel to 3.8.0.
docker: relocation error: docker: symbol
dm_task_get_info_with_deferred_remove, version Base not defined in
file libdevmapper.so.1.02 with
link time reference
表面上是说内核版本过低,实际上是device-mapper库版本过低
解决办法:
yum upgrade device-mapper-libs
CentOS官方base源中有提供device-mapper-libs
四.测试
查看版本
docker version
[root@ct7 ~]# docker version
Client:
Server:
测试工作是否正常,获取最新的centos镜像
docker pull centos:latest
root@router:~#docker images
REPOSITORY
ubuntu
centos
运行简单的bash shell来测试这个镜像
docker run -i -t centos /bin/bash
如果正常,会获得一个简单的bash提示,输入exit退出
查看IP
ip a
docker rmi -f 2fa927b5cdd3 #删除镜像