docker-ce版本安装+镜像加速

docker-ce安装

设置docker-ce镜像源docker-ce为社区免费版本
yum-config-manager –add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo ###添加repo源
sed -i ‘s/download.docker.com/mirrors.aliyun.com\/docker-ce/g’ /etc/yum.repos.d/docker-ce.repo ###sed -i ‘s/要被替换的字符串/新的字符串/g’ 文件名
yum makecache fast ###makecache表示生成或更新缓存 fast是一个选项,用来告诉 yum 尽可能快地(但不完整)更新缓存,而不是下载所有可用的元数据,它通常会获取最新的 repomd.xml 文件和一些基本的包信息,以便进行基本的包搜索和安装操作。
yum -y install docker-ce ###安装docker-ce

docker 镜像加速

不使用镜像加速会报如下错误:
Error response from daemon: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
来自守护进程的错误响应:Get“https://registry-1.docker”。. io/v2/”: net/http:请求在等待连接时被取消。等待报头时超时
如下方式网上说管用 经验证不起作用
获取镜像加速器地址 https://cr.console.aliyun.com/cn-beijing/instances
ACR会为每一个账号(阿里云账号或RAM用户)生成一个镜像加速器地址,配置镜像加速器前,您需要获取镜像加速器地址。
1、登录容器镜像服务控制台。
2、在左侧导航栏选择镜像工具 > 镜像加速器
3、在镜像加速器页面获取加速器地址。


20241120日验证下面方法可以正常pull但是search是不成功的
cat /etc/docker/daemon.json
{
“registry-mirrors” :
[
“https://docker.m.daocloud.io”,
“https://noohub.ru”,
“https://huecker.io”,
“https://dockerhub.timeweb.cloud”
]
}

[root@test-docker ~]# docker search nginx ###search不成功
Error response from daemon: Get “https://index.docker.io/v1/search?q=nginx&n=25”: dial tcp 202.160.129.36:443: i/o timeout
[root@test-docker ~]# docker pull nginx:1.20.1
1.20.1: Pulling from library/nginx
b380bbd43752: Pull complete
83acae5e2daa: Pull complete
33715b419f9b: Pull complete
eb08b4d557d8: Pull complete
74d5bdecd955: Pull complete
0820d7f25141: Pull complete
Digest: sha256:a98c2360dcfe44e9987ed09d59421bb654cb6c4abe50a92ec9c912f252461483
Status: Downloaded newer image for nginx:1.20.1
docker.io/library/nginx:1.20.1
[root@test-docker ~]# docker pull mysql:5.7.44
5.7.44: Pulling from library/mysql
20e4dcae4c69: Pull complete
1c56c3d4ce74: Pull complete
e9f03a1c24ce: Pull complete
68c3898c2015: Pull complete
6b95a940e7b6: Pull complete
90986bb8de6e: Pull complete
ae71319cb779: Pull complete
ffc89e9dfd88: Pull complete
43d05e938198: Pull complete
064b2d298fba: Pull complete
df9a4d85569b: Pull complete
Digest: sha256:4bc6bc963e6d8443453676cae56536f4b8156d78bae03c0145cbe47c2aad73bb
Status: Downloaded newer image for mysql:5.7.44
docker.io/library/mysql:5.7.44
[root@test-docker ~]# docker pull php:7.4.33-fpm
7.4.33-fpm: Pulling from library/php
a603fa5e3b41: Pull complete
c428f1a49423: Pull complete
156740b07ef8: Pull complete
fb5a4c8af82f: Pull complete
972155ae644b: Pull complete
a8e3b94fe6c1: Pull complete
93346a3f46bc: Pull complete
b922b67ca46b: Pull complete
6137f893bda6: Pull complete
79b1a1b78461: Pull complete
Digest: sha256:3ac7c8c74b2b047c7cb273469d74fc0d59b857aa44043e6ea6a0084372811d5b
Status: Downloaded newer image for php:7.4.33-fpm
docker.io/library/php:7.4.33-fpm
[root@test-docker ~]# docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7.44 5107333e08a8 11 months ago 501MB
php 7.4.33-fpm 38f2b691dcb8 2 years ago 443MB
nginx 1.20.1 c8d03f6b8b91 3 years ago 133MB