​官方步骤​

1.配置好虚拟机(CentOS7及以上)且接外网

[root@echohye ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

2.卸载旧版本

(若之前没装过,此步省略)
​​​/​​表示连接符而已

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

3. 下载安装gcc相关库

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

4.安装需要的软件包

yum install -y yum-utils

5.设置stable镜像仓库

# 官方的(不推荐,国内网速不友好)
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 阿里云yyds
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6.更新yum软件包索引(可选)

yum makecache fast

7.安装Docker Engine

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

8.启动docker

systemctl start docker
[root@echohye ~]# ps -df | grep docker
root 5768 5203 0 23:20 pts/1 00:00:00 grep --color=auto docker
[root@echohye ~]# ps -ef | grep docker
root 5649 1 1 23:20 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 5770 5203 0 23:20 pts/1 00:00:00 grep --color=auto docker

9.测试

[root@echohye ~]# docker version
Client: Docker Engine - Community
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:05:12 2022
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:03:33 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.7
GitCommit: 0197261a30bf81f1ee8e6a4dd2dea0ef95d67ccb
runc:
Version: 1.1.3
GitCommit: v1.1.3-0-g6724737
docker-init:
Version: 0.19.0
GitCommit: de40ad0

10.卸载

systemctl stop docker

yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin

rm -rf /var/lib/docker

sudo rm -rf /var/lib/containerd

11.阿里云镜像加速

注:当然不一定要用阿里云的镜像,也可以用国内其它的镜像

注册​​阿里云账号​​——>控制台——>菜单——>容器镜像服务

Docker安装步骤_git

个人学习,就选了​​个人实例​

Docker安装步骤_docker_02

创建之后,点击镜像工具——>镜像加速器

Docker安装步骤_linux_03


Docker安装步骤_linux_04

箴言:因为这些东西是非常简单的。不要抱怨自己学不会,那是因为你没有足够用心。