构建后端为etcd的CoreDNS的容器集群(二)、下载最新的etcd容器镜像

在尝试获取etcd的容器的最新版本镜像时,使用latest作为tag取到的并非最新版本,本文尝试用实际最新版本的版本号进行pull,从而取到想的最新版etcd容器镜像。

一、用latest作为tag尝试下载最新etcd的镜像

1、下载镜像
bash 复制代码
[root@localhost opt]# docker pull quay.io/coreos/etcd:latest
latest: Pulling from coreos/etcd
ff3a5c916c92: Pull complete 
96b0e24539ea: Pull complete 
d1eca4d01894: Pull complete 
ad732d7a61c2: Pull complete 
8bc526247b5c: Pull complete 
5f56944bb51c: Pull complete 
Digest: sha256:5b6691b7225a3f77a5a919a81261bbfb31283804418e187f7116a0a9ef65d21d
Status: Downloaded newer image for quay.io/coreos/etcd:latest
2、查看镜像
bash 复制代码
[root@localhost opt]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
quay.io/coreos/etcd   latest              61ad63875109        6 years ago         39.5MB

显示镜像创建日期为6年前,太离谱了

3、拉一个容器,查看镜像的具体版本
bash 复制代码
[root@localhost opt]# docker run -d   -p 2379:2379   -p 2380:2380   --name etcd   quay.io/coreos/etcd  /usr/local/bin/etcd   -advertise-client-urls http://0.0.0.0:2379   -listen-client-urls http://0.0.0.0:2379   -initial-advertise-peer-urls http://0.0.0.0:2380   -listen-peer-urls http://0.0.0.0:2380   -initial-cluster default=http://0.0.0.0:2380                          
7874cc64d5aeec551d805bcbc26965d51d3c291a704411b2b604e2735e7fe7a9
[root@localhost opt]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                              NAMES
7874cc64d5ae        quay.io/coreos/etcd   "/usr/local/bin/etcd..."   5 seconds ago       Up 3 seconds        0.0.0.0:2379-2380->2379-2380/tcp   etcd
[root@localhost opt]# docker exec -it  etcd /bin/sh
/ # 
/ # ps -ef
PID   USER     TIME   COMMAND
    1 root       0:00 /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -initial-advertise-peer-urls http://0.0.0.0:2380 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster def
   18 root       0:00 /bin/sh
   29 root       0:00 ps -ef
/ # cd /usr/local/bin/
/usr/local/bin # etcd --version
etcd Version: 3.3.8
Git SHA: 33245c6b5
Go Version: go1.9.7
Go OS/Arch: linux/amd64

可见当前容器内的etcd版本为3.3.8,老的离谱。

二、查找etcd最新的正式版版本

查看etcd官方文档Documentation versions | etcd,可以看到当前最新的稳定版本为3.5.16

三、尝试用 3.5.16为tag拉取最新的etcd容器镜像

1、尝试拉取
bash 复制代码
[root@localhost opt]# docker pull quay.io/coreos/etcd:v3.5.16
v3.5.16: Pulling from coreos/etcd
804c8aba2cc6: Pull complete 
2ae710cd8bfe: Pull complete 
d462aa345367: Pull complete 
0f8b424aa0b9: Pull complete 
d557676654e5: Pull complete 
c8022d07192e: Pull complete 
d858cbc252ad: Pull complete 
1069fc2daed1: Pull complete 
b40161cd83fc: Pull complete 
5318d93a3a65: Pull complete 
307c1adadb60: Pull complete 
fbb01d9e9dc9: Pull complete 
fbfea02ac3cf: Pull complete 
8c26e4bf18e2: Pull complete 
1e59a65f8816: Pull complete 
ffbd4ca5f0bd: Pull complete 
Digest: sha256:d967d98a12dc220a1a290794711dba7eba04b8ce465e12b02383d1bfbb33e159
Status: Downloaded newer image for quay.io/coreos/etcd:v3.5.16
[root@localhost opt]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
quay.io/coreos/etcd   v3.5.16             8523cb381f23        5 weeks ago         59MB

可以看到镜像文件创建日期为几周前,应该是比较新了。

2、拉起容器检查应用程序版本
bash 复制代码
[root@localhost opt]# docker run -d   -p 2379:2379   -p 2380:2380   --name etcd   quay.io/coreos/etcd:v3.5.16  /usr/local/bin/etcd   -advertise-client-urls http://0.0.0.0:2379   -listen-client-urls http://0.0.0.0:2379   -initial-advertise-peer-urls http://0.0.0.0:2380   -listen-peer-urls http://0.0.0.0:2380   -initial-cluster default=http://0.0.0.0:2380 
225f0db2c3920b035659878f321f3d3cbda483acf5f11201b96653c48c16a8d5
[root@localhost opt]# docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                              NAMES
225f0db2c392        quay.io/coreos/etcd:v3.5.16   "/usr/local/bin/etcd..."   17 minutes ago      Up 17 minutes       0.0.0.0:2379-2380->2379-2380/tcp   etcd
[root@localhost opt]# docker exec -it  etcd /usr/local/bin/etcd --version
etcd Version: 3.5.16
Git SHA: f20bbad
Go Version: go1.22.7
Go OS/Arch: linux/amd64

可以看到当前程序包版本确为 3.5.16,达到目的。

总结:当pull拉取镜像时,可能由于镜像源维护的问题,导致用lasted作为tag拉到的并不是该容器的最新版,而需要结合实际应用的版本信息,用目标版本作为tag来pull,才能拿到真正想要的新版本。

相关推荐
爱喝水的鱼丶9 小时前
SAP-ABAP:SAP基础数据校验工具开发系列博客(共5篇)第五篇:性能优化与上线运维:保障高并发场景下的工具稳定运行
运维·学习·性能优化·sap·abap·erp·经验交流
闪电悠米9 小时前
黑马点评-秒杀优化-01_async_seckill_idea
java·数据库·ide·redis·分布式·缓存·intellij-idea
企服AI产品测评局9 小时前
2026年Agent元年!深度解析实在Agent未来路线图:从自动化工具到全能数字员工的跃迁
运维·人工智能·ai·chatgpt·自动化
Leo.yuan9 小时前
运维视角下的数据同步工具选型指南:2026年主流方案功能对比
运维
秋漓9 小时前
Nginx学习与应用
运维·学习·nginx
TDengine (老段)9 小时前
TDengine 数据修复与迁移 — VGroup 调度、S3 外挂与运维操作
大数据·运维·数据库·物联网·时序数据库·iot·tdengine
努力努力再努力wz10 小时前
【Qt入门系列】一文掌握 Qt 常用显示类控件:QLCDNumber、QProgressBar 与 QCalendarWidget
c语言·开发语言·数据结构·数据库·c++·git·qt
KaiwuDB10 小时前
KaiwuDB 开源校园行扬州大学站 | 点亮开源成长之路
数据库·开源
utf8mb4安全女神10 小时前
shell中的判断语法
linux·运维·服务器
玫幽倩10 小时前
2026盘古石取证决赛(APK取证)
数据库·python·电子取证·aes·隐藏·笔记软件·手机取证