(25年版)在CentOS 7.9 系统上构建docker

1. 查看系统当前内核信息,要求系统是64位,且内核版本为3.10版本

image

[root@localhost ~]# uname -r
3.10.0-1160.el7.x86_64

2.查看版本信息

image

[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

3.暂时关闭防火墙

image

[root@localhost ~]# systemctl stop firewalld

4.永久关闭防火墙

image

[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

 5.由于centos 7已经停更,因此需要移除原有的centsos.base基础镜像,再重新拉取

image

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

6.重新下载Centos-Base基础镜像

image

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2025-08-06 22:08:43--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 42.202.213.239, 117.66.50.79, 117.66.50.77, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|42.202.213.239|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[============================================================================================>] 2,523       --.-K/s 用时 0s      

2025-08-06 22:08:43 (492 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

7.安装gcc相关环境,确保虚拟机可以上外网

image

[root@localhost ~]# yum -y install gcc
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                           | 3.6 kB  00:00:00     
extras                                                                                                         | 2.9 kB  00:00:00     
updates                                                                                                        | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                                  | 153 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                              | 253 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                             |  27 MB  00:00:04     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: (28, 'Connection timed out after 30002 milliseconds')
正在尝试其它镜像。
(4/4): base/7/x86_64/primary_db                                                                                | 6.1 MB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 gcc.x86_64.0.4.8.5-44.el7 将被 安装
--> 正在处理依赖关系 cpp = 4.8.5-44.el7,它被软件包 gcc-4.8.5-44.el7.x86_64 需要
--> 正在处理依赖关系 glibc-devel >= 2.2.90-12,它被软件包 gcc-4.8.5-44.el7.x86_64 需要
--> 正在检查事务
---> 软件包 cpp.x86_64.0.4.8.5-44.el7 将被 安装
---> 软件包 glibc-devel.x86_64.0.2.17-326.el7_9.3 将被 安装
--> 正在处理依赖关系 glibc-headers = 2.17-326.el7_9.3,它被软件包 glibc-devel-2.17-326.el7_9.3.x86_64 需要
--> 正在处理依赖关系 glibc = 2.17-326.el7_9.3,它被软件包 glibc-devel-2.17-326.el7_9.3.x86_64 需要
--> 正在处理依赖关系 glibc-headers,它被软件包 glibc-devel-2.17-326.el7_9.3.x86_64 需要
--> 正在检查事务
---> 软件包 glibc.x86_64.0.2.17-317.el7 将被 升级
--> 正在处理依赖关系 glibc = 2.17-317.el7,它被软件包 glibc-common-2.17-317.el7.x86_64 需要
---> 软件包 glibc.x86_64.0.2.17-326.el7_9.3 将被 更新
---> 软件包 glibc-headers.x86_64.0.2.17-326.el7_9.3 将被 安装
--> 正在处理依赖关系 kernel-headers >= 2.2.1,它被软件包 glibc-headers-2.17-326.el7_9.3.x86_64 需要
--> 正在处理依赖关系 kernel-headers,它被软件包 glibc-headers-2.17-326.el7_9.3.x86_64 需要
--> 正在检查事务
---> 软件包 glibc-common.x86_64.0.2.17-317.el7 将被 升级
---> 软件包 glibc-common.x86_64.0.2.17-326.el7_9.3 将被 更新
---> 软件包 kernel-headers.x86_64.0.3.10.0-1160.119.1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

======================================================================================================================================
 Package                          架构                     版本                                       源                         大小
======================================================================================================================================
正在安装:
 gcc                              x86_64                   4.8.5-44.el7                               base                       16 M
为依赖而安装:
 cpp                              x86_64                   4.8.5-44.el7                               base                      5.9 M
 glibc-devel                      x86_64                   2.17-326.el7_9.3                           updates                   1.1 M
 glibc-headers                    x86_64                   2.17-326.el7_9.3                           updates                   692 k
 kernel-headers                   x86_64                   3.10.0-1160.119.1.el7                      updates                   9.1 M
为依赖而更新:
 glibc                            x86_64                   2.17-326.el7_9.3                           updates                   3.6 M
 glibc-common                     x86_64                   2.17-326.el7_9.3                           updates                    12 M

事务概要
======================================================================================================================================
安装  1 软件包 (+4 依赖软件包)
升级           ( 2 依赖软件包)

总下载量:48 M
Downloading packages:
No Presto metadata available for updates
警告:/var/cache/yum/x86_64/7/updates/packages/glibc-2.17-326.el7_9.3.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEYA 
glibc-2.17-326.el7_9.3.x86_64.rpm 的公钥尚未安装
(1/7): glibc-2.17-326.el7_9.3.x86_64.rpm                                                                       | 3.6 MB  00:00:00     
cpp-4.8.5-44.el7.x86_64.rpm 的公钥尚未安装           32% [=============                             ] 8.8 MB/s |  15 MB  00:00:03 ETA 
(2/7): cpp-4.8.5-44.el7.x86_64.rpm                                                                             | 5.9 MB  00:00:01     
(3/7): glibc-devel-2.17-326.el7_9.3.x86_64.rpm                                                                 | 1.1 MB  00:00:00     
(4/7): glibc-headers-2.17-326.el7_9.3.x86_64.rpm                                                               | 692 kB  00:00:00     
(5/7): glibc-common-2.17-326.el7_9.3.x86_64.rpm                                                                |  12 MB  00:00:02     
(6/7): kernel-headers-3.10.0-1160.119.1.el7.x86_64.rpm                                                         | 9.1 MB  00:00:01     
(7/7): gcc-4.8.5-44.el7.x86_64.rpm                                                                             |  16 MB  00:00:02     
--------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                   17 MB/s |  48 MB  00:00:02     
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : glibc-2.17-326.el7_9.3.x86_64                                                                                     1/9 
  正在更新    : glibc-common-2.17-326.el7_9.3.x86_64                                                                              2/9 
  正在安装    : cpp-4.8.5-44.el7.x86_64                                                                                           3/9 
  正在安装    : kernel-headers-3.10.0-1160.119.1.el7.x86_64                                                                       4/9 
  正在安装    : glibc-headers-2.17-326.el7_9.3.x86_64                                                                             5/9 
  正在安装    : glibc-devel-2.17-326.el7_9.3.x86_64                                                                               6/9 
  正在安装    : gcc-4.8.5-44.el7.x86_64                                                                                           7/9 
  清理        : glibc-2.17-317.el7.x86_64                                                                                         8/9 
  清理        : glibc-common-2.17-317.el7.x86_64                                                                                  9/9 
  验证中      : glibc-common-2.17-326.el7_9.3.x86_64                                                                              1/9 
  验证中      : glibc-headers-2.17-326.el7_9.3.x86_64                                                                             2/9 
  验证中      : glibc-devel-2.17-326.el7_9.3.x86_64                                                                               3/9 
  验证中      : glibc-2.17-326.el7_9.3.x86_64                                                                                     4/9 
  验证中      : cpp-4.8.5-44.el7.x86_64                                                                                           5/9 
  验证中      : gcc-4.8.5-44.el7.x86_64                                                                                           6/9 
  验证中      : kernel-headers-3.10.0-1160.119.1.el7.x86_64                                                                       7/9 
  验证中      : glibc-common-2.17-317.el7.x86_64                                                                                  8/9 
  验证中      : glibc-2.17-317.el7.x86_64                                                                                         9/9 

已安装:
  gcc.x86_64 0:4.8.5-44.el7                                                                                                           

作为依赖被安装:
  cpp.x86_64 0:4.8.5-44.el7                        glibc-devel.x86_64 0:2.17-326.el7_9.3    glibc-headers.x86_64 0:2.17-326.el7_9.3   
  kernel-headers.x86_64 0:3.10.0-1160.119.1.el7   

作为依赖被升级:
  glibc.x86_64 0:2.17-326.el7_9.3                                glibc-common.x86_64 0:2.17-326.el7_9.3                               

完毕!

8..安装gcc-c++相关环境,确保虚拟机可以上外网

image

[root@localhost ~]# yum -y install gcc-c++
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gcc-c++.x86_64.0.4.8.5-44.el7 将被 安装
--> 正在处理依赖关系 libstdc++-devel = 4.8.5-44.el7,它被软件包 gcc-c++-4.8.5-44.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libstdc++-devel.x86_64.0.4.8.5-44.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

======================================================================================================================================
 Package                              架构                        版本                                源                         大小
======================================================================================================================================
正在安装:
 gcc-c++                              x86_64                      4.8.5-44.el7                        base                      7.2 M
为依赖而安装:
 libstdc++-devel                      x86_64                      4.8.5-44.el7                        base                      1.5 M

事务概要
======================================================================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:8.7 M
安装大小:25 M
Downloading packages:
(1/2): libstdc++-devel-4.8.5-44.el7.x86_64.rpm                                                                 | 1.5 MB  00:00:00     
(2/2): gcc-c++-4.8.5-44.el7.x86_64.rpm                                                                         | 7.2 MB  00:00:01     
--------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                  6.4 MB/s | 8.7 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libstdc++-devel-4.8.5-44.el7.x86_64                                                                               1/2 
  正在安装    : gcc-c++-4.8.5-44.el7.x86_64                                                                                       2/2 
  验证中      : gcc-c++-4.8.5-44.el7.x86_64                                                                                       1/2 
  验证中      : libstdc++-devel-4.8.5-44.el7.x86_64                                                                               2/2 

已安装:
  gcc-c++.x86_64 0:4.8.5-44.el7                                                                                                       

作为依赖被安装:
  libstdc++-devel.x86_64 0:4.8.5-44.el7                                                                                               

完毕!

9.安装需要的软件包

image

[root@localhost ~]# yum install -y yum-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理

 10.添加设置阿里云官方镜像源

image

[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件: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

11.更新yum软件包索引

image

[root@localhost ~]# yum makecache fast
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
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/updateinfo                                                                    |   55 B  00:00:00     
(2/2): docker-ce-stable/7/x86_64/primary_db                                                                    | 152 kB  00:00:00     
元数据缓存已建立

12.构建社区版docker

image

[root@localhost ~]# yum -y install docker-ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.26.1.4-1.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 containerd.io >= 1.6.24,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-26.1.4-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
---> 软件包 containerd.io.x86_64.0.1.6.33-3.1.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.26.1.4-1.el7 将被 安装
--> 正在处理依赖关系 docker-buildx-plugin,它被软件包 1:docker-ce-cli-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-compose-plugin,它被软件包 1:docker-ce-cli-26.1.4-1.el7.x86_64 需要
---> 软件包 docker-ce-rootless-extras.x86_64.0.26.1.4-1.el7 将被 安装
--> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-26.1.4-1.el7.x86_64 需要
--> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-26.1.4-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 docker-buildx-plugin.x86_64.0.0.14.1-1.el7 将被 安装
---> 软件包 docker-compose-plugin.x86_64.0.2.27.1-1.el7 将被 安装
---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装
--> 正在检查事务
---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

======================================================================================================================================
 Package                               架构               版本                                     源                            大小
======================================================================================================================================
正在安装:
 docker-ce                             x86_64             3:26.1.4-1.el7                           docker-ce-stable              27 M
为依赖而安装:
 container-selinux                     noarch             2:2.119.2-1.911c772.el7_8                extras                        40 k
 containerd.io                         x86_64             1.6.33-3.1.el7                           docker-ce-stable              35 M
 docker-buildx-plugin                  x86_64             0.14.1-1.el7                             docker-ce-stable              14 M
 docker-ce-cli                         x86_64             1:26.1.4-1.el7                           docker-ce-stable              15 M
 docker-ce-rootless-extras             x86_64             26.1.4-1.el7                             docker-ce-stable             9.4 M
 docker-compose-plugin                 x86_64             2.27.1-1.el7                             docker-ce-stable              13 M
 fuse-overlayfs                        x86_64             0.7.2-6.el7_8                            extras                        54 k
 fuse3-libs                            x86_64             3.6.1-4.el7                              extras                        82 k
 slirp4netns                           x86_64             0.4.3-4.el7_8                            extras                        81 k

事务概要
======================================================================================================================================
安装  1 软件包 (+9 依赖软件包)

总下载量:114 M
安装大小:401 M
Downloading packages:
(1/10): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                   |  40 kB  00:00:06     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm 的公钥尚未安装
(2/10): docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm                                                           |  14 MB  00:00:09     
(3/10): containerd.io-1.6.33-3.1.el7.x86_64.rpm                                                                |  35 MB  00:00:12     
(4/10): docker-ce-26.1.4-1.el7.x86_64.rpm                                                                      |  27 MB  00:00:03     
(5/10): docker-ce-rootless-extras-26.1.4-1.el7.x86_64.rpm                                                      | 9.4 MB  00:00:01     
(6/10): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                |  54 kB  00:00:00     
(7/10): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                      |  82 kB  00:00:00     
(8/10): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                   |  81 kB  00:00:00     
(9/10): docker-ce-cli-26.1.4-1.el7.x86_64.rpm                                                                  |  15 MB  00:00:02     
(10/10): docker-compose-plugin-2.27.1-1.el7.x86_64.rpm                                                         |  13 MB  00:00:02     
--------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                  6.8 MB/s | 114 MB  00:00:16     
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                               1/10 
  正在安装    : containerd.io-1.6.33-3.1.el7.x86_64                                                                              2/10 
  正在安装    : docker-buildx-plugin-0.14.1-1.el7.x86_64                                                                         3/10 
  正在安装    : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                 4/10 
  正在安装    : fuse3-libs-3.6.1-4.el7.x86_64                                                                                    5/10 
  正在安装    : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                              6/10 
  正在安装    : docker-compose-plugin-2.27.1-1.el7.x86_64                                                                        7/10 
  正在安装    : 1:docker-ce-cli-26.1.4-1.el7.x86_64                                                                              8/10 
  正在安装    : docker-ce-rootless-extras-26.1.4-1.el7.x86_64                                                                    9/10 
  正在安装    : 3:docker-ce-26.1.4-1.el7.x86_64                                                                                 10/10 
  验证中      : docker-compose-plugin-2.27.1-1.el7.x86_64                                                                        1/10 
  验证中      : fuse3-libs-3.6.1-4.el7.x86_64                                                                                    2/10 
  验证中      : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                              3/10 
  验证中      : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                 4/10 
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                               5/10 
  验证中      : containerd.io-1.6.33-3.1.el7.x86_64                                                                              6/10 
  验证中      : 3:docker-ce-26.1.4-1.el7.x86_64                                                                                  7/10 
  验证中      : 1:docker-ce-cli-26.1.4-1.el7.x86_64                                                                              8/10 
  验证中      : docker-ce-rootless-extras-26.1.4-1.el7.x86_64                                                                    9/10 
  验证中      : docker-buildx-plugin-0.14.1-1.el7.x86_64                                                                        10/10 

已安装:
  docker-ce.x86_64 3:26.1.4-1.el7                                                                                                     

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8                    containerd.io.x86_64 0:1.6.33-3.1.el7                         
  docker-buildx-plugin.x86_64 0:0.14.1-1.el7                            docker-ce-cli.x86_64 1:26.1.4-1.el7                           
  docker-ce-rootless-extras.x86_64 0:26.1.4-1.el7                       docker-compose-plugin.x86_64 0:2.27.1-1.el7                   
  fuse-overlayfs.x86_64 0:0.7.2-6.el7_8                                 fuse3-libs.x86_64 0:3.6.1-4.el7                               
  slirp4netns.x86_64 0:0.4.3-4.el7_8                                   

完毕!

13.暂时启动docker

image

[root@localhost ~]# systemctl start docker

14.Linux系统开机永久启动

image

[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

15.查看docker版本

image

[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           26.1.4
 API version:       1.45
 Go version:        go1.21.11
 Git commit:        5650f9b
 Built:             Wed Jun  5 11:32:04 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.1.4
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       de5c9cf
  Built:            Wed Jun  5 11:31:02 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.33
  GitCommit:        d2d58213f83a351ca8f528a95fbd145f5654e957
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

16.华为镜像加速器的配置

先去注册华为云账号,然后获取自己的镜像加速器地址

注册的获取的步骤参考我的帖子链接:华为云镜像加速器配置 - 红酒人生 - 博客园

image

[root@localhost ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
 {
 "registry-mirrors": ["https://每个人自己特有的地址.mirror.swr.myhuaweicloud.com"]
 }
EOF

sudo tee /etc/docker/daemon.json <<-'EOF'
 {
 "registry-mirrors": ["https://每个人自己特有的华为云地址.mirror.swr.myhuaweicloud.com"]
 }
EOF

获取自己的地址后做上面中文的替代,然后执行

17.加载配置文件

image

[root@localhost ~]# sudo systemctl daemon-reload

18.重启docker

image

[root@localhost ~]# systemctl restart docker

19.查看docker信息,确认是否已经确认配置好了华为镜像加速器

image

[root@localhost ~]# docker info
Client: Docker Engine - Community
 Version:    26.1.4
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 26.1.4
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d2d58213f83a351ca8f528a95fbd145f5654e957
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 3.10.0-1160.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.682GiB
 Name: localhost
 ID: 15203fe2-17d2-45a0-9450-3c7c3782f3d1
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://e79b8883af6a43e69455bdd296e3ce9c.mirror.swr.myhuaweicloud.com/
 Live Restore Enabled: false

 

原创技术贴: 2025年8月6日 22:56
尊重原创,转载请附转载路径!


posted @ 2025-08-06 22:45  红酒人生  阅读(142)  评论(0)    收藏  举报