问题描述
Note: You’re trying to push a manifest list/index which references multiple platform specific manifests, but not all of them are available locally or available to the remote repository.
Make sure you have all the referenced content and try again
当我们使用docker pull 去拉取一个支持多平台镜像,再把它推送到其他镜像仓库时,可能会报这个错误。由于平台镜像的manifest文件包含多个平台,而你pull默认只会拉取当前操作系统的平台,类似执行了:docker pull --platform linux/amd64。去push的时候,由于manifest上定义的其它平台的镜像找不到,所以报错。
解决方案
这里以weaviate镜像为例,整个思路是:
- 查看manifest文件,确认镜像支持哪些平台
- 拉取你需要平台的镜像,修改tag后上传
- 创建多平台的manifest,将特定平台镜像加入到这个多平台manifest后上传。
- 查看镜像的manifest文件
docker manifest inspect semitechnologies/weaviate:1.25.7
# 输出
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 1626,
"digest": "sha256:57521bc9730de02b7af614d844fddfe07f52e0589cafa92aef625abe5ade1e9d",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 1626,
"digest": "sha256:5b0236662d5f87e439b71cef2ea5d14214212173f493c6abd1e0bdc15d3ad64a",
"platform": {
"architecture": "arm64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 566,
"digest": "sha256:2cc9c2db447f31365699bd4a84aafccfb9782bbf33bcb6e558b45e66790990e2",
"platform": {
"architecture": "unknown",
"os": "unknown"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 566,
"digest": "sha256:12034a71c32f5961eb871c86f2fd53fca789d3d36b9cf3688dad5f1ff471d764",
"platform": {
"architecture": "unknown",
"os": "unknown"
}
}
]
}
- 下载指定平台的镜像,修改tag后push
# 拉取镜像,hash信息从manifest文件获取
docker pull semitechnologies/weaviate:1.25.7@sha256:57521bc9730de02b7af614d844fddfe07f52e0589cafa92aef625abe5ade1e9d
docker pull semitechnologies/weaviate:1.25.7@sha256:5b0236662d5f87e439b71cef2ea5d14214212173f493c6abd1e0bdc15d3ad64a
# 修改镜像tag
docker tag semitechnologies/weaviate:1.25.7@sha256:57521bc9730de02b7af614d844fddfe07f52e0589cafa92aef625abe5ade1e9d registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7-amd64
docker tag semitechnologies/weaviate:1.25.7@sha256:5b0236662d5f87e439b71cef2ea5d14214212173f493c6abd1e0bdc15d3ad64a registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7-arm64
# push镜像
docker push registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7-amd64
docker push registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7-arm64
- 创建多平台manifest后push
# 创建manifest
docker manifest create registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7 --amend registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7-amd64 --amend registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7-arm64
# push
docker manifest push registry.cn-shenzhen.aliyuncs.com/docker-mirror2/weaviate:1.25.7