目录
概述
本文介绍在centos下如何安装docker
安装依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
添加docker源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装docker
sudo yum install docker-ce
卸载旧版本(可选)
如果安装过程中有类似报错是因为有旧版本
Transaction check error:
file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
卸载旧版本
sudo yum erase docker-engine-selinux
sudo yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
或者
sudo yum remove docker docker-common docker-selinux docker-engine
然后再重试安装
sudo yum install docker-ce
查看docker版本
docker -v
启动docker
systemctl start docker
开机默认启动docker
systemctl enable docker
检查docker运行状态
systemctl status docker
验证docker安装
跑一个docker hello world
docker run hello-world
安装特定版本docker
查询有哪些可安装版本
yum list docker-ce --showduplicates | sort -r
如果不加--showduplicates
则只会显示最新版本
sort -r
降序排列
安装特定版本
sudo yum install docker-ce-<VERSION STRING>
最新评论