并非所有图像都已由其维护者签名。您得到的错误是因为该特定图像未由该图像的维护者签名。
例如,签名的图像是 nginx 图像。
$ docker trust inspect nginx:alpine
[
{
"Name": "nginx:alpine",
"SignedTags": [
{
"SignedTag": "alpine",
"Digest": "1e9c503db9913a59156f78c6420f6e2f01c8a3b71ceeeddcd7f604c4db0f045e",
"Signers": [
"Repo Admin"
]
}
],
"Signers": [],
"AdministrativeKeys": [
{
"Name": "Root",
"Keys": [
{
"ID": "d2f02ea35ebffce87d31673efbff44c199b1af0be042989d4655a176e8aad40d"
}
]
},
{
"Name": "Repository",
"Keys": [
{
"ID": "ec92eb8e988506253f8590cb924b6becdbb0520f2fb430257d8879e2d3bed2cc"
}
]
}
]
}
]
因此,您可以在启用内容信任的情况下提取此图像。
$ DOCKER_CONTENT_TRUST=true docker pull nginx:alpine
Pull (1 of 1): nginx:alpine@sha256:1e9c503db9913a59156f78c6420f6e2f01c8a3b71ceeeddcd7f604c4db0f045e
docker.io/library/nginx@sha256:1e9c503db9913a59156f78c6420f6e2f01c8a3b71ceeeddcd7f604c4db0f045e: Pulling from library/nginx
Digest: sha256:1e9c503db9913a59156f78c6420f6e2f01c8a3b71ceeeddcd7f604c4db0f045e
Status: Image is up to date for nginx@sha256:1e9c503db9913a59156f78c6420f6e2f01c8a3b71ceeeddcd7f604c4db0f045e
Tagging nginx@sha256:1e9c503db9913a59156f78c6420f6e2f01c8a3b71ceeeddcd7f604c4db0f045e as nginx:alpine
docker.io/library/nginx:alpine
但是,在启用内容信任的情况下,无法提取未签名的图像。
$ docker trust inspect docker/whalesay
[]
No signatures or cannot access docker/whalesay
如您所见,我将得到与您相同的错误。
$ DOCKER_CONTENT_TRUST=true docker pull docker/whalesay
Using default tag: latest
Error: remote trust data does not exist for docker.io/docker/whalesay: notary.docker.io does not have trust data for docker.io/docker/whalesay
如果您想使用已签名的图像,一种方法是自己签名并推送您自己的存储库。
export DOCKER_CONTENT_TRUST=true # enable content trust globally
DOCKER_CONTENT_TRUST=false docker pull docker/whalesay # download unsiged image by disabling content trust
docker tag docker/whalesay marcofranssen/whalesay
docker push marcofranssen/whalesay # pushes and signs the image in my own repository with my keys
docker trust inspect marcofranssen/whalesay
[
{
"Name": "marcofranssen/whalesay",
"SignedTags": [
{
"SignedTag": "latest",
"Digest": "4a79736c5f63638261bc21228b48e9991340ca6d977b73de3598be20606e5d87",
"Signers": [
"marcofranssen"
]
}
],
"Signers": [
{
"Name": "marcofranssen",
"Keys": [
{
"ID": "eb9dd99255f91efeba139941fbfdb629f11c2353704de07a2ad653d22311c88b"
}
]
}
],
"AdministrativeKeys": [
{
"Name": "Root",
"Keys": [
{
"ID": "0428c356406a6ea3543012855c117d13d784774e49aa6db461cfbad5726d187b"
}
]
},
{
"Name": "Repository",
"Keys": [
{
"ID": "b635efeddff59751e8b6b59abb45383555103d702e7d3f46fbaaa9a8ac144ab8"
}
]
}
]
}
]
现在,您可以将自己的存储库与图像的签名版本一起使用。不用说,您应该只在验证图像内容后对图像进行签名。