Skip to content

Instantly share code, notes, and snippets.

@wolfv
Created September 8, 2021 13:08
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfv/fc04f85b2bd0141326f6ecff03d9b101 to your computer and use it in GitHub Desktop.
Save wolfv/fc04f85b2bd0141326f6ecff03d9b101 to your computer and use it in GitHub Desktop.
Fetch from OCI registry (ghcr.io)
export TOKEN=$(curl --silent https://ghcr.io/token\?scope\=repository:wolfv/artifact:pull | jq -r .token)
curl \
--silent \
--request 'GET' \
--header "Authorization: Bearer $TOKEN" \
--header "Accept: application/vnd.oci.image.manifest.v1+json" \
'https://ghcr.io/v2/wolfv/artifact/manifests/1.0'
echo "\n\nFetching image content now:\n\n"
curl \
--location \
--request GET \
--header "Authorization: Bearer ${TOKEN}" \
"https://ghcr.io/v2/wolfv/artifact/blobs/sha256:c5be3ea75353851e1fcf3a298af3b6cfd2af3d7ff018ce52657b6dbd8f986aa4"
@joonas-fi
Copy link

Thank you! 👏

@boriselec
Copy link

to save to file add

curl \
--output file \

@maltfield
Copy link

Doesn't work :(

user@disp897:~$ curl \
--location \
--request GET \
--header "Authorization: Bearer ${TOKEN}" \
"https://ghcr.io/v2/wolfv/artifact/blobs/sha256:c5be3ea75353851e1fcf3a298af3b6cfd2af3d7ff018ce52657b6dbd8f986aa4"
{"errors":[{"code":"BLOB_UNKNOWN","message":"blob unknown to registry"}]}
user@disp897:~$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment