Docker 安装记录(CentOS)

卸载旧版本

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.

1
2
3
4
5
6
7
8
9
10
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine

It’s OK if yum reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. The Docker CE package is now called docker-ce.

安装 Docker CE

使用 repository 安装

设置 repository

1.添加引用包

1
2
3
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2

2.添加 repository 地址

官方源
1
2
3
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
国内源
1
2
3
$ sudo yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装

1
sudo yum install docker-ce

启动 Docker CE

1
sudo systemctl start docker

开机自动启动

1
sudo systemctl enable docker

安装完毕
参考地址:https://docs.docker.com/install/linux/docker-ce/centos/#install-docker-ce-1