centos 7 yum安裝docker
注意:Docker 要求 CentOS 系統的內核版本高于 3.10 ,查看本頁面的前提條件來驗證你的CentOS 版本是否支持 Docker 。
**1.通過 uname -r 命令查看你當前的內核版本 **
[root@VM_0_2_centos ~]#uname -r
2.卸載老版本的 docker 及其相關依賴
[root@VM_0_2_centos ~]#yum remove docker docker-common \
container-selinux docker-selinux docker-engine
3.安裝需要的軟件包(yum-util 提供yum-config-manager功能,另外兩個是devicemapper驅動依賴的)
[root@VM_0_2_centos ~]#yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
4.添加官方yum源
[root@VM_0_2_centos ~]#yum-config-manager \
--add-repo https://download.docker.com/linux/centos/docker-ce.repo
由于網速問題,建議使用國內源。執行下列命令添加yum軟件源:
[root@VM_0_2_centos ~]#yum-config-manager --add-repo \
https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
5.更新索引
[root@VM_0_2_centos ~]#yum makecache fast
6.安裝 docker-ce
[root@VM_0_2_centos ~]#yum install -y docker-ce
7.啟動并加入開機啟動
[root@VM_0_2_centos ~]#systemctl start docker
[root@VM_0_2_centos ~]#systemctl enable docker
8.配置鏡像加速器
你可以選擇阿里云加速器,DaoCloud加速器等Docker 版本在 1.12 或更高
修改 /etc/docker/daemon.json 文件并添加上 registry-mirrors 鍵值。
[root@VM_0_2_centos ~]#vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
[root@VM_0_2_centos ~]#systemctl daemon-reload
[root@VM_0_2_centos ~]#systemctl restart docker
9.驗證是否安裝成功(有client和service兩部分表示docker安裝啟動都成功)
[root@VM_0_2_centos ~]#docker version
浙公網安備 33010602011771號