centos7.2下安装docker-ce(docker-ce:社区版 docker-ee:企业版)
1.卸载旧版本安装包:
yum remove docker docker-common docker-selinux docker-engine
2.安装依赖包:
yum install -y yum-utils device-mapper-persistent-data lvm2
3.添加yum 源仓库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 如果下载不了,可以使用阿里云的镜像:
# yum config-manager -add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.清除 yum 缓存,重新加载yum源, 这一步要执行一下,不然会报错
yum clean all
yum makecache
5.下载安装docker-ce
yum install docker-ce
6.配置docker hub加速器
[root@oracle01 ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6cda0f16.m.daocloud.io
会提示
docker version >= 1.12
{"registry-mirrors": ["http://6cda0f16.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker
7.重启一下docker安装完成
systemctl restart docker
systemctl enable docker
备注:执行 systemctl stop docker 后提示“Warning: Stopping docker.service, but it can still be activated by: docker.socket”,则再执行systemctl stop docker.socket即可
8.将指定用户添加到用户组 添加后可以不适用root启动
usermod -aG docker your_username
9.docker默认安装运行目录 /var/lib/docker/
10.通过软链接修改docker数据存储目录(例如放到/home下)
systemctl stop docker
systemctl stop docker.socket
mv /var/lib/docker /usr/share/nginx/
ln -s /usr/share/nginx/docker /var/lib