【记录贴】docker镜像格式报错

1,错误内容

最近想要补一补docker的基础知识,跟着练习的时候,发现下面的错误。

换了其他镜像(docker pull ubuntu)也存在同样的问题:

错误内容:docker: mediaType in manifest should be 'application/vnd.docker.distribution.manifest.v2+json' not 'application/vnd.oci.image.manifest.v1+json'.

复制代码
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
docker: mediaType in manifest should be 'application/vnd.docker.distribution.manifest.v2+json' not 'application/vnd.oci.image.manifest.v1+json'.

2,发生原因

查看内容提示,可以看出,原因是期待的镜像格式是'application/vnd.docker.distribution.manifest.v2+json',但是下载下来的镜像格式是'application/vnd.oci.image.manifest.v1+json'.,所以检查不通过,报错。

问题1:这个格式用来干啥?

简单来说,镜像清单描述了一个 Docker 镜像的各种组成部分,告诉用户一个镜像是如何组成的。有多种格式,上面也只是其中两种。

参考下面文章:
K8S 1.20 弃用 Docker 评估之:Docker 和 OCI 镜像格式的差别-腾讯云开发者社区-腾讯云 (tencent.com)

问题2:这两个格式的区别

我的理解,application/vnd.docker.distribution.manifest.v2+json是docker工具(容器管理工具除了docker,还有其他,比如podman)这边自己的格式,application/vnd.oci.image.manifest.v1+json更加通用(除了docker,其他容器管理工具也能用)。

看了一下dockerhub上的镜像,一些最新的镜像也都转成后者了。

问题3:为啥会报错?

本地docker版本太低,不支持application/vnd.oci.image.manifest.v1+json格式。

3,如何解决?

解决1:升级docker版本,将docker升级到比较新的能够支持application/vnd.oci.image.manifest.v1+json格式的版本(具体多少之后支持,这个需要查一下),有知道的小伙伴可以call我一下。(我用的第二种方法)

解决2:拉取镜像的时候,采用比较旧的镜像(还是application/vnd.docker.distribution.manifest.v2+json的格式)。

可以去docker hub上面看一下有没有格式相关的信息,或者去对应的github上查看更新履历。

hub.docker.com

相关推荐
Danileaf_Guo2 小时前
256台H100服务器算力中心的带外管理网络建设方案
运维·服务器
拾贰_C4 小时前
【Linux | Windows | Terminal Command】 Linux---grep | Windows--- findstr
linux·运维·服务器
bloglin999994 小时前
启动容器报错ls: cannot access ‘/docker-entrypoint-initdb.d/‘: Operation not permitted
docker·容器·eureka
songjxin5 小时前
离线部署kubernetes v1.34.3
云原生·容器·kubernetes
虹科网络安全5 小时前
艾体宝洞察 | 利用“隐形字符”的钓鱼邮件:传统防御为何失效,AI安全意识培训如何补上最后一道防线
运维·网络·安全
石像鬼₧魂石5 小时前
Kali Linux 网络端口深度扫描
linux·运维·网络
alengan5 小时前
linux上面写python3日志服务器
linux·运维·服务器
yBmZlQzJ6 小时前
免费内网穿透-端口转发配置介绍
运维·经验分享·docker·容器·1024程序员节
JH30736 小时前
docker 新手入门:10分钟搞定基础使用
运维·docker·容器
小卒过河01047 小时前
使用apache nifi 从数据库文件表路径拉取远程文件至远程服务器目的地址
运维·服务器·数据库