1. 查看系统内核版本
# 查看CentOS版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
# 查看内核版本
[root@localhost ~]# uname -r
3.10.0-1127.el7.x86_64
docker运行在centos7上时,要求系统为64位,系统内核版本在3.10以上
2. 卸载旧版本
旧版本的Docker将其连同相关的依赖项一起卸载
[root@localhost ~]# sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
3. 开始安装
(1)安装一些必要系统软件
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.huaweicloud.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 device-mapper-persistent-data-0.8.5-2.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 lvm2.x86_64.7.2.02.186-7.el7 将被 升级
---> 软件包 lvm2.x86_64.7.2.02.186-7.el7_8.2 将被 更新
--> 正在处理依赖关系 lvm2-libs = 7:2.02.186-7.el7_8.2,它被软件包 7:lvm2-2.02.186-7.el7_8.2.x86_64 需要
---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 安装
--> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要
--> 正在处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要
--> 正在检查事务
---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7.4 将被 安装
---> 软件包 lvm2-libs.x86_64.7.2.02.186-7.el7 将被 升级
---> 软件包 lvm2-libs.x86_64.7.2.02.186-7.el7_8.2 将被 更新
--> 正在处理依赖关系 device-mapper-event = 7:1.02.164-7.el7_8.2,它被软件包 7:lvm2-libs-2.02.186-7.el7_8.2.x86_64 需要
---> 软件包 python-kitchen.noarch.0.1.1.1-5.el7 将被 安装
--> 正在处理依赖关系 python-chardet,它被软件包 python-kitchen-1.1.1-5.el7.noarch 需要
--> 正在检查事务
---> 软件包 device-mapper-event.x86_64.7.1.02.164-7.el7 将被 升级
---> 软件包 device-mapper-event.x86_64.7.1.02.164-7.el7_8.2 将被 更新
--> 正在处理依赖关系 device-mapper-event-libs = 7:1.02.164-7.el7_8.2,它被软件包 7:device-mapper-event-1.02.164-7.el7_8.2.x86_64 需要
--> 正在处理依赖关系 device-mapper = 7:1.02.164-7.el7_8.2,它被软件包 7:device-mapper-event-1.02.164-7.el7_8.2.x86_64 需要
---> 软件包 python-chardet.noarch.0.2.2.1-3.el7 将被 安装
--> 正在检查事务
---> 软件包 device-mapper.x86_64.7.1.02.164-7.el7 将被 升级
--> 正在处理依赖关系 device-mapper = 7:1.02.164-7.el7,它被软件包 7:device-mapper-libs-1.02.164-7.el7.x86_64 需要
---> 软件包 device-mapper.x86_64.7.1.02.164-7.el7_8.2 将被 更新
---> 软件包 device-mapper-event-libs.x86_64.7.1.02.164-7.el7 将被 升级
---> 软件包 device-mapper-event-libs.x86_64.7.1.02.164-7.el7_8.2 将被 更新
--> 正在检查事务
---> 软件包 device-mapper-libs.x86_64.7.1.02.164-7.el7 将被 升级
---> 软件包 device-mapper-libs.x86_64.7.1.02.164-7.el7_8.2 将被 更新
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================
正在安装:
yum-utils noarch 1.1.31-54.el7_8 updates 122 k
正在更新:
lvm2 x86_64 7:2.02.186-7.el7_8.2 updates 1.3 M
为依赖而安装:
libxml2-python x86_64 2.9.1-6.el7.4 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
为依赖而更新:
device-mapper x86_64 7:1.02.164-7.el7_8.2 updates 295 k
device-mapper-event x86_64 7:1.02.164-7.el7_8.2 updates 191 k
device-mapper-event-libs x86_64 7:1.02.164-7.el7_8.2 updates 190 k
device-mapper-libs x86_64 7:1.02.164-7.el7_8.2 updates 324 k
lvm2-libs x86_64 7:2.02.186-7.el7_8.2 updates 1.1 M
事务概要
===================================================================================================================
安装 1 软件包 (+3 依赖软件包)
升级 1 软件包 (+5 依赖软件包)
总下载量:4.2 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/10): device-mapper-1.02.164-7.el7_8.2.x86_64.rpm | 295 kB 00:00:00
(2/10): device-mapper-event-1.02.164-7.el7_8.2.x86_64.rpm | 191 kB 00:00:00
(3/10): libxml2-python-2.9.1-6.el7.4.x86_64.rpm | 247 kB 00:00:00
(4/10): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00
(5/10): device-mapper-libs-1.02.164-7.el7_8.2.x86_64.rpm | 324 kB 00:00:00
(6/10): lvm2-2.02.186-7.el7_8.2.x86_64.rpm | 1.3 MB 00:00:00
(7/10): lvm2-libs-2.02.186-7.el7_8.2.x86_64.rpm | 1.1 MB 00:00:00
(8/10): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
(9/10): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
(10/10): device-mapper-event-libs-1.02.164-7.el7_8.2.x86_64.rpm | 190 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------
总计 4.5 MB/s | 4.2 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : 7:device-mapper-1.02.164-7.el7_8.2.x86_64 1/16
正在更新 : 7:device-mapper-libs-1.02.164-7.el7_8.2.x86_64 2/16
正在更新 : 7:device-mapper-event-libs-1.02.164-7.el7_8.2.x86_64 3/16
正在更新 : 7:device-mapper-event-1.02.164-7.el7_8.2.x86_64 4/16
正在更新 : 7:lvm2-libs-2.02.186-7.el7_8.2.x86_64 5/16
正在安装 : python-chardet-2.2.1-3.el7.noarch 6/16
正在安装 : python-kitchen-1.1.1-5.el7.noarch 7/16
正在安装 : libxml2-python-2.9.1-6.el7.4.x86_64 8/16
正在安装 : yum-utils-1.1.31-54.el7_8.noarch 9/16
正在更新 : 7:lvm2-2.02.186-7.el7_8.2.x86_64 10/16
清理 : 7:lvm2-2.02.186-7.el7.x86_64 11/16
清理 : 7:lvm2-libs-2.02.186-7.el7.x86_64 12/16
清理 : 7:device-mapper-event-1.02.164-7.el7.x86_64 13/16
清理 : 7:device-mapper-event-libs-1.02.164-7.el7.x86_64 14/16
清理 : 7:device-mapper-1.02.164-7.el7.x86_64 15/16
清理 : 7:device-mapper-libs-1.02.164-7.el7.x86_64 16/16
验证中 : libxml2-python-2.9.1-6.el7.4.x86_64 1/16
验证中 : python-chardet-2.2.1-3.el7.noarch 2/16
验证中 : 7:lvm2-libs-2.02.186-7.el7_8.2.x86_64 3/16
验证中 : 7:device-mapper-event-1.02.164-7.el7_8.2.x86_64 4/16
验证中 : 7:device-mapper-libs-1.02.164-7.el7_8.2.x86_64 5/16
验证中 : python-kitchen-1.1.1-5.el7.noarch 6/16
验证中 : 7:lvm2-2.02.186-7.el7_8.2.x86_64 7/16
验证中 : yum-utils-1.1.31-54.el7_8.noarch 8/16
验证中 : 7:device-mapper-1.02.164-7.el7_8.2.x86_64 9/16
验证中 : 7:device-mapper-event-libs-1.02.164-7.el7_8.2.x86_64 10/16
验证中 : 7:device-mapper-1.02.164-7.el7.x86_64 11/16
验证中 : 7:lvm2-2.02.186-7.el7.x86_64 12/16
验证中 : 7:device-mapper-event-libs-1.02.164-7.el7.x86_64 13/16
验证中 : 7:device-mapper-libs-1.02.164-7.el7.x86_64 14/16
验证中 : 7:device-mapper-event-1.02.164-7.el7.x86_64 15/16
验证中 : 7:lvm2-libs-2.02.186-7.el7.x86_64 16/16
已安装:
yum-utils.noarch 0:1.1.31-54.el7_8
作为依赖被安装:
libxml2-python.x86_64 0:2.9.1-6.el7.4 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
更新完毕:
lvm2.x86_64 7:2.02.186-7.el7_8.2
作为依赖被升级:
device-mapper.x86_64 7:1.02.164-7.el7_8.2 device-mapper-event.x86_64 7:1.02.164-7.el7_8.2
device-mapper-event-libs.x86_64 7:1.02.164-7.el7_8.2 device-mapper-libs.x86_64 7:1.02.164-7.el7_8.2
lvm2-libs.x86_64 7:2.02.186-7.el7_8.2
完毕!
(2)添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror
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
(3)更新yum软件包索引,提高搜索安装软件的速度
sudo yum makecache fast
[root@localhost ~]# yum makecache fast
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.huaweicloud.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/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/x86_64/primary_db | 46 kB 00:00:00
元数据缓存已建立
(4)安装 Docker-ce
dudo yum -y install docker-ce
[root@localhost ~]# sudo yum -y install docker-ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.huaweicloud.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.19.03.13-3.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 3:docker-ce-19.03.13-3.el7.x86_64 需要
--> 正在处理依赖关系 containerd.io >= 1.2.2-3,它被软件包 3:docker-ce-19.03.13-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-19.03.13-3.el7.x86_64 需要
--> 正在处理依赖关系 libcgroup,它被软件包 3:docker-ce-19.03.13-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
--> 正在处理依赖关系 policycoreutils-python,它被软件包 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 需要
---> 软件包 containerd.io.x86_64.0.1.3.7-3.1.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.19.03.13-3.el7 将被 安装
---> 软件包 libcgroup.x86_64.0.0.41-21.el7 将被 安装
--> 正在检查事务
---> 软件包 policycoreutils-python.x86_64.0.2.5-34.el7 将被 安装
--> 正在处理依赖关系 setools-libs >= 3.3.8-4,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libsemanage-python >= 2.5-14,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 audit-libs-python >= 2.1.3-4,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 python-IPy,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.4)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.2)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4(VERS_4.0)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 checkpolicy,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1()(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4()(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要
--> 正在检查事务
---> 软件包 audit-libs-python.x86_64.0.2.8.5-4.el7 将被 安装
---> 软件包 checkpolicy.x86_64.0.2.5-8.el7 将被 安装
---> 软件包 libsemanage-python.x86_64.0.2.5-14.el7 将被 安装
---> 软件包 python-IPy.noarch.0.0.75-6.el7 将被 安装
---> 软件包 setools-libs.x86_64.0.3.3.8-4.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
========================================================================================================================================================================================================================
Package 架构 版本 源 大小
========================================================================================================================================================================================================================
正在安装:
docker-ce x86_64 3:19.03.13-3.el7 docker-ce-stable 24 M
为依赖而安装:
audit-libs-python x86_64 2.8.5-4.el7 base 76 k
checkpolicy x86_64 2.5-8.el7 base 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
containerd.io x86_64 1.3.7-3.1.el7 docker-ce-stable 29 M
docker-ce-cli x86_64 1:19.03.13-3.el7 docker-ce-stable 38 M
libcgroup x86_64 0.41-21.el7 base 66 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-4.el7 base 620 k
事务概要
========================================================================================================================================================================================================================
安装 1 软件包 (+10 依赖软件包)
总下载量:93 M
安装大小:390 M
Downloading packages:
(1/11): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(2/11): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(3/11): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-19.03.13-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY ] 3.6 MB/s | 28 MB 00:00:17 ETA
docker-ce-19.03.13-3.el7.x86_64.rpm 的公钥尚未安装
(4/11): docker-ce-19.03.13-3.el7.x86_64.rpm | 24 MB 00:00:07
(5/11): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(6/11): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(7/11): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(8/11): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(9/11): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(10/11): docker-ce-cli-19.03.13-3.el7.x86_64.rpm | 38 MB 00:00:13
(11/11): containerd.io-1.3.7-3.1.el7.x86_64.rpm | 29 MB 00:00:23
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 3.9 MB/s | 93 MB 00:00:24
从 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
正在安装 : libcgroup-0.41-21.el7.x86_64 1/11
正在安装 : setools-libs-3.3.8-4.el7.x86_64 2/11
正在安装 : audit-libs-python-2.8.5-4.el7.x86_64 3/11
正在安装 : checkpolicy-2.5-8.el7.x86_64 4/11
正在安装 : python-IPy-0.75-6.el7.noarch 5/11
正在安装 : 1:docker-ce-cli-19.03.13-3.el7.x86_64 6/11
正在安装 : libsemanage-python-2.5-14.el7.x86_64 7/11
正在安装 : policycoreutils-python-2.5-34.el7.x86_64 8/11
正在安装 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 9/11
正在安装 : containerd.io-1.3.7-3.1.el7.x86_64 10/11
正在安装 : 3:docker-ce-19.03.13-3.el7.x86_64 11/11
验证中 : libsemanage-python-2.5-14.el7.x86_64 1/11
验证中 : containerd.io-1.3.7-3.1.el7.x86_64 2/11
验证中 : 3:docker-ce-19.03.13-3.el7.x86_64 3/11
验证中 : 1:docker-ce-cli-19.03.13-3.el7.x86_64 4/11
验证中 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 5/11
验证中 : python-IPy-0.75-6.el7.noarch 6/11
验证中 : checkpolicy-2.5-8.el7.x86_64 7/11
验证中 : policycoreutils-python-2.5-34.el7.x86_64 8/11
验证中 : audit-libs-python-2.8.5-4.el7.x86_64 9/11
验证中 : setools-libs-3.3.8-4.el7.x86_64 10/11
验证中 : libcgroup-0.41-21.el7.x86_64 11/11
已安装:
docker-ce.x86_64 3:19.03.13-3.el7
作为依赖被安装:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.3.7-3.1.el7 docker-ce-cli.x86_64 1:19.03.13-3.el7
libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
完毕!
(5)启动 Docker 服务
sudo systemctl start docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]#
(6)查看运行状态
sudo systemctl status docker
[root@localhost ~]# 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 五 2020-10-30 11:34:06 CST; 1min 0s ago
Docs: https://docs.docker.com
Main PID: 18235 (dockerd)
Tasks: 8
Memory: 37.9M
CGroup: /system.slice/docker.service
└─18235 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
10月 30 11:34:05 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:05.373560019+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
10月 30 11:34:05 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:05.373572322+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 ..." module=grpc
10月 30 11:34:05 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:05.373581046+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
10月 30 11:34:05 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:05.401468391+08:00" level=info msg="Loading containers: start."
10月 30 11:34:05 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:05.779530713+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option ...d IP address"
10月 30 11:34:05 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:05.992828630+08:00" level=info msg="Loading containers: done."
10月 30 11:34:06 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:06.007234711+08:00" level=info msg="Docker daemon" commit=4484c46d9d graphdriver(s)=overlay2 version=19.03.13
10月 30 11:34:06 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:06.008022677+08:00" level=info msg="Daemon has completed initialization"
10月 30 11:34:06 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
10月 30 11:34:06 localhost.localdomain dockerd[18235]: time="2020-10-30T11:34:06.032074677+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
(7)查看版本
sudo docker version
[root@localhost ~]# docker version
Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:03:45 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:21 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
4. 配置镜像加速地址
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,可以使用网易云镜像加速或者阿里云镜像加速
一般使用阿里云镜像加速:
(1)登录阿里云控制台
进入阿里云控制台首页,点击产品与服务,搜索镜像,点击容器镜像服务进入:(2)获取镜像加速地址
点击镜像加速器地址,获取镜像加速器地址
(3)配置加速地址
在 /etc/docker/daemon.json
文件中配置,没有daemon.json
文件可创建一个,将刚刚获取的镜像加速地址配置进去
[root@localhost docker]# cat daemon.json
{
"registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
[root@localhost docker]#
(4)重新加载并重启
[root@localhost docker]# systemctl daemon-reload
[root@localhost docker]# systemctl restart docker
(5)试试查找镜像
[root@localhost docker]# docker search jdk
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
primetoninc/jdk Oracle jdk 1.8, 1.7 19 [OK]
ascdc/jdk8 jdk8 10 [OK]
codenvy/jdk8_maven3_tomcat8 JDK 8, Maven 3, Tomcat 8 9 [OK]
ringcentral/jdk an alpine Linux image included glibc and Ora… 7
codenvy/jdk7_tomcat7 Dockerfile https://github.com/codenvy/docker… 7
gmaslowski/jdk Oracle JDK8 6
openkbs/jdk-mvn-py3 Java 8/11 OpenJDK + Maven + Python 3+ pip +… 6 [OK]
codenvy/jdk7 Dockerfile https://github.com/codenvy/docker… 3
codenvy/jdk7_vnc Dockerfile https://github.com/codenvy/docker… 3
codenvy/jdk7_jetty9 Dockerfile https://github.com/codenvy/docker… 2
openkbs/jdk11-mvn-py3 Java JDK 11 + Maven 3 + Python 3 + Gradle 4 2 [OK]
codenvy/jdk7_jboss7 Dockerfile https://github.com/codenvy/docker… 2
openkbs/jdk-mvn-py Java JDK 8 + Maven 3 + Python 2 1 [OK]
andonescu/jdk-8-node-docker-gcp jdk8 node docker gcp 1
payneteasy/jdk-8 Java 8 for using with gitlab-ci 1 [OK]
ukhydrographicoffice/jdk8-python36 Build image that contains bash, jdk 8 and py… 0
jdk1/php-redis-modified 0
wealthsimple/jdk 0
ping2ravi/jdk All Java/JDK Versions 0 [OK]
uquote/jdk8-tomee1.7.3-plume Apache Tomee Plume with Oracle JDK 8 on Cent… 0
dwetzel/jdk-ant JDK8 + ANT 0 [OK]
guligo/jdk-maven-ant Tool stack consisting of Oracle JDK, Maven a… 0 [OK]
payneteasy/jdk-8-js jdk-8, maven and javascript 0 [OK]
king019/jdk jdk 0
infinitenature/jdk JDK Images for all jdks jabba supports 0
[root@localhost docker]#
查找成功即可使用了!