Update Answered in the comments. I missed the sha256 prefix for digests in the manifest.json!
I am experimenting with the Registry v2 API using shell scripts and cannot seem to finalize the image push.
I followed the API docs and pushed the layers (one tar.gz and config.json). Both uploads were completed with status code 201.
< HTTP/1.1 201 Created
< content-length: 0
< docker-content-digest: sha256:e251e682f7e64cff127020015be3254313b3a7900f54d82ecf34653192be4c21
< docker-distribution-api-version: registry/2.0
< location: https://registry.hub.docker.com/v2/ravikanth/cnc2/blobs/sha256:e251e682f7e64cff127020015be3254313b3a7900f54d82ecf34653192be4c21
< date: Mon, 28 Nov 2022 13:43:31 GMT
< strict-transport-security: max-age=31536000
< HTTP/1.1 201 Created
< content-length: 0
< docker-content-digest: sha256:4500bf72b8876e180985cb9d30dcbfb4b37c6212af4a1e66f6a59e9c44e4430e
< docker-distribution-api-version: registry/2.0
< location: https://registry.hub.docker.com/v2/ravikanth/cnc2/blobs/sha256:4500bf72b8876e180985cb9d30dcbfb4b37c6212af4a1e66f6a59e9c44e4430e
< date: Mon, 28 Nov 2022 14:03:00 GMT
< strict-transport-security: max-age=31536000
I could verify that these layers exist.
date: Mon, 28 Nov 2022 14:03:50 GMT
content-type: application/octet-stream
content-length: 277
cf-ray: 7713a639ae0326b9-BLR
accept-ranges: bytes
cache-control: public, max-age=14400
etag: "6ff6ee3576fbb38ded464213e5119f93"
expires: Mon, 28 Nov 2022 18:03:50 GMT
last-modified: Mon, 28 Nov 2022 09:38:20 GMT
vary: Accept-Encoding
cf-cache-status: MISS
x-amz-id-2: BKOqrxyDQlWoyu/lv9AiyoCUMqImMVJROkFCpvHrtNdU1YDdjGJSQLoR E J7sYlyo9AwQd27Ao=
x-amz-request-id: D9F9EP13RA3VY9TJ
x-amz-version-id: y1TMXGkb8nPxCq1Ojxp7P0FbwmfurXTs
server: cloudflare
HTTP/2 200
date: Mon, 28 Nov 2022 14:02:00 GMT
content-type: application/octet-stream
content-length: 1074934
cf-ray: 7713a3862b8f1d89-BLR
accept-ranges: bytes
cache-control: public, max-age=14400
etag: "bb6070a00aab579e87f54126c0147bf6"
expires: Mon, 28 Nov 2022 18:02:00 GMT
last-modified: Mon, 28 Nov 2022 08:57:53 GMT
vary: Accept-Encoding
cf-cache-status: MISS
x-amz-id-2: ZIwf 5xaaHuHdQhCtErlXXXxfKZA3GPFSP2CTm1TbYS8caRh53bjxJ2yj/jGRTUPXQ0fHdTXIDs=
x-amz-request-id: FZH3XXP4VP2C354S
x-amz-version-id: 0ZKPRYiiGUKn5dc_rISx4jHKcKTH3rfR
server: cloudflare
Now, when I finally try to push the manifest, I am getting the following response.
{"errors":[{"code":"DIGEST_INVALID","message":"provided digest did not match uploaded content"},{"code":"MANIFEST_BLOB_UNKNOWN","message":"blob unknown to registry","detail":"4500bf72b8876e180985cb9d30dcbfb4b37c6212af4a1e66f6a59e9c44e4430e"},{"code":"DIGEST_INVALID","message":"provided digest did not match uploaded content"},{"code":"MANIFEST_BLOB_UNKNOWN","message":"blob unknown to registry","detail":"e251e682f7e64cff127020015be3254313b3a7900f54d82ecf34653192be4c21"}]}
What is wrong?
This is how I derived the digests/diff.
LAYERDIGEST=$(sha256sum < hello-cloud.tar.gz | cut -d' ' -f1)
LAYERDIFF=$(gunzip < hello-cloud.tar.gz | sha256sum | cut -d' ' -f1)
LAYERSIZE=$(ls -l hello-cloud.tar.gz | awk '{print $5}')
CONFIGDIGEST=$(sha256sum < configuration.json | cut -d' ' -f1)
CONFIGSIZE=$(ls -l configuration.json | awk '{print $5}')
And, here is the manifest.json
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1 json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1 json",
"size": 277,
"digest": "4500bf72b8876e180985cb9d30dcbfb4b37c6212af4a1e66f6a59e9c44e4430e"
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar gzip",
"size": 1074934,
"digest": "e251e682f7e64cff127020015be3254313b3a7900f54d82ecf34653192be4c21"
}
]
}
And, configuration.json
{
"architecture": "amd64",
"os": "linux",
"config": {
},
"rootfs": {
"type": "layers",
"diff_ids": [
"sha256:690fa2812df903a4cee676e28389e154fe022f2a26fb29c4c97e9c6583fa5bc6"
]
},
"history": [
{
"created_by": "Ravikanth C"
}
]
}
CodePudding user response:
Your config and layer digests in the manifest are missing the sha256:
prefix. Modify the manifest like this:
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1 json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1 json",
"size": 277,
"digest": "sha256:4500bf72b8876e180985cb9d30dcbfb4b37c6212af4a1e66f6a59e9c44e4430e"
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar gzip",
"size": 1074934,
"digest": "sha256:e251e682f7e64cff127020015be3254313b3a7900f54d82ecf34653192be4c21"
}
]
}