-
I’m using GHCR as my container registry. The GitOps automation we use breaks if an engineer specifies an image that doesn’t exist. For example, if the last built image is Is there a way use the GHCR v2 http API or the GitHub API to check if a specific image/tag combination exists? And what PAT scopes are needed for the check (if it is available)? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 9 replies
-
GHCR supports the Docker Registry API. You could either try to download the specific tag and see if you get a valid manifest, or retrieve the list of tags and check if the tag shows up. You’ll need to use a token with read:packages scope for the requests. That said, maybe it’s better to catch and handle the error that currently occurs instead of adding a separate check? After all, the error occurring already tells you that the tag doesn’t exist. 😉 |
Beta Was this translation helpful? Give feedback.
-
I’m asking specifically because other topics reference portions of the Docker Registry API that haven’t been implemented yet (e.g. Additionally, we are using a third-party GitOps package which breaks when it tries to install an image that doesn’t exist. So we’re opting to check the GitOps definition during the lint/test phrase before even executing the GitOps process. |
Beta Was this translation helpful? Give feedback.
-
You can use the You’ll need a token for this like a PAT. (soon this will work with the Here’s an example:
|
Beta Was this translation helpful? Give feedback.
-
Now that ghcr.io supports GITHUB_TOKEN, you can do the following
Cheers |
Beta Was this translation helpful? Give feedback.
-
Based on @13013SwagR’s answer, here is my shell script version for Bash/command line. Creating Personal Access Token (PAT) to access Github container registry
Listing available tags for a container on GHCRFirst set your PAT in
Should give your PAT token that looks lke:
The PAT needs to be converted to base64 encoding for GHCR REST API.
To list tags for organisation/user
You should get a JSON reply like:
Here is also our Github Actions build recipe how to build and push images to GCHR. |
Beta Was this translation helpful? Give feedback.
-
REST services are okay, but what would really help users out is a basic search frontend, like Docker Hub enjoys. |
Beta Was this translation helpful? Give feedback.
-
How can we list all the docker images that we have on the GitHub container registry? |
Beta Was this translation helpful? Give feedback.
-
It's difficult to query without a webui |
Beta Was this translation helpful? Give feedback.
-
where is the documentation to use the API ? |
Beta Was this translation helpful? Give feedback.
You can use the
tags/list
endpoint to grab all available tags.You’ll need a token for this like a PAT. (soon this will work with the
GITHUB_TOKEN
)Here’s an example: