【记录贴】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

相关推荐
IT利刃出鞘几秒前
Docker Compose--解决容器时间不正确的问题
运维·docker·容器
山上三树5 分钟前
进程状态详解
linux·运维·服务器
山上三树7 分钟前
task_struct 详解
运维·服务器·网络
oMcLin14 分钟前
如何打造Linux运维监控平台:Prometheus + Grafana实战与性能优化
linux·运维·prometheus
木卫二号Coding36 分钟前
jupyterlab-安装与启动
linux·运维·服务器
fengyehongWorld1 小时前
Linux logger命令
linux·运维·服务器
一只鹿鹿鹿1 小时前
网络信息与数据安全建设方案
大数据·运维·开发语言·网络·mysql
好好学习啊天天向上1 小时前
最新:ubuntu上源码安装llvm,还没有成功
linux·运维·ubuntu
小宇的天下2 小时前
Calibre nmDRC 运行机制与规则文件(13-2)
运维·开发语言
Guistar~~2 小时前
【Linux驱动开发IMX6ULL】使用NXP MfgTool 烧写系统到eMMC
linux·运维·驱动开发