CentOS 7.8 安装 Docker

1.卸载旧版本

sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

2.安装依赖

sudo yum -y install gcc
sudo yum -y install gcc-c++

3.安装软件包

sudo yum install -y yum-utils

4.设置 stable 镜像仓库(使用国内阿里云仓库链接下载)

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

5.更新 yum 软件包索引

sudo yum makecache fast

6.安装 Docker 引擎

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

7.启动 Docker

sudo systemctl start docker    # 启动
sudo systemctl status docker   # 查看状态
sudo systemctl enable docker   # 设置开机自启
sudo ps -ef | grep docker      # 查看进程

8.测试

sudo docker run hello-world

9.卸载

systemctl stop docker
yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin
rm -rf /var/lib/docker
rm -rf /var/lib/containerd

10.设置开机启动

systemctl enable docker.service

11.关闭开机启动

systemctl disable docker.service

你可能感兴趣的:(centos,docker,linux)