CentOS中快速安装Docker

快速安装

1
curl -sSL https://get.docker.com/ | sh
1
curl -sSL https://get.daocloud.io/docker | sh
1
curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -

手动安装

卸载旧版本

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

设置yum仓库

1
2
3
4
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

安装Docker引擎

注意:docker-compose-plugin即安装docker-compose,不需要再进行手动安装

1
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

启动Docker

1
2
sudo systemctl start docker
sudo systemctl enable docker

卸载Docker

停止Docker

1
2
sudo systemctl stop docker
sudo systemctl stop docker.socket

卸载 Docker Engine、CLI、Containerd 和 Docker Compose 软件包

1
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

清除镜像、容器、数据卷或自定义配置文件

1
2
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd