文档课题:Linux操作系统下docker的安装.
系统:centos 7.9 64位
1、删旧版docker
[root@Leo-Docker ~]# yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
podman \
runc

2、安装依赖包
[root@Leo-Docker ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

3、配置yum
[root@Leo-Docker ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@Leo-Docker ~]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: ftp.sjtu.edu.cn
base                                                                                                                   | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                       | 3.5 kB  00:00:00     
extras                                                                                                                 | 2.9 kB  00:00:00     
updates                                                                                                                | 2.9 kB  00:00:00     
(1/2): docker-ce-stable/7/x86_64/primary_db                                                                            | 116 kB  00:00:00     
(2/2): docker-ce-stable/7/x86_64/updateinfo                                                                            |   55 B  00:00:00     
Metadata Cache Created

4、安装docker
[root@Leo-Docker ~]# yum -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin

5、启动docker
[root@Leo-Docker ~]# systemctl start docker
[root@Leo-Docker ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-08-13 22:22:31 CST; 33s ago
     Docs: https://docs.docker.com
 Main PID: 3818 (dockerd)
    Tasks: 10
   Memory: 31.5M
   CGroup: /system.slice/docker.service
           └─3818 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Aug 13 22:22:30 Leo-Docker systemd[1]: Starting Docker Application Container Engine...
Aug 13 22:22:30 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:30.369512946+08:00" level=info msg="Starting up"
Aug 13 22:22:30 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:30.458217901+08:00" level=info msg="Loading containers: start."
Aug 13 22:22:31 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:31.367880091+08:00" level=info msg="Firewalld: interface docker0 al...urning"
Aug 13 22:22:31 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:31.493809091+08:00" level=info msg="Loading containers: done."
Aug 13 22:22:31 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:31.542200866+08:00" level=info msg="Docker daemon" commit=a61e2b4 g...=24.0.5
Aug 13 22:22:31 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:31.542423043+08:00" level=info msg="Daemon has completed initialization"
Aug 13 22:22:31 Leo-Docker dockerd[3818]: time="2023-08-13T22:22:31.591476278+08:00" level=info msg="API listen on /run/docker.sock"
Aug 13 22:22:31 Leo-Docker systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

-开机自启
[root@Leo-Docker ~]# systemctl enable docker

6、相关查询
[root@Leo-Docker ~]# docker version
Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:39:02 2023
 OS/Arch:           linux/amd64
 Context:           default
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

[root@Leo-Docker ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

--拉取官方hello-world镜像
[root@Leo-Docker ~]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
719385e32844: Pull complete 

^C
[root@Leo-Docker ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    9c7a54a9a43c   3 months ago   13.3kB

参考网址:
https://www.bilibili.com/video/BV1vY4y1X7vP/?spm_id_from=333.337.search-card.all.click&vd_source=8c872e2fd1d99229b38a73ed6718b776