CentOS 7使用yum安装Docker
安装依赖
# 配置阿里云源 # 备份 cp /etc/yum.repos.d/CentOS-Base.repo{,.bak'_'`date +%Y%m%d_%H%M%S`} # 下载 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 生效测试 yum clean all yum makecache # 配置epel源 yum install -y epel-release # 备份(如有配置其他epel源) cp /etc/yum.repos.d/epel.rep{,.bak'_'`date +%Y%m%d_%H%M%S`} cp /etc/yum.repos.d/epel-testing.repo{,.bak'_'`date +%Y%m%d_%H%M%S`} # 下载新repo到/etc/yum.repos.d/ wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
卸载旧依赖
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine
安装Docker CE
# 设置存储库 yum install -y yum-utils \ device-mapper-persistent-data \ lvm2 yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum-config-manager --enable docker-ce-edge # yum-config-manager --enable docker-ce-test # yum-config-manager --disable docker-ce-edge yum makecache fast yum install -y docker-ce
# 安装指定版本
# yum install -y docker-ce-18.06.1.ce-3.el7
创建用户组
groupadd docker
usermod -aG docker root
usermod -aG docker www-data
设置启动项
systemctl enable docker service docker start
全自动脚本: