I want to know what images are uploaded to a specific owner in GitHub Container Registry. Containers are referred like this: https://ghcr.io/OWNER/<imageName>:<imageTag>
How to list all images from an account in GitHub Container Registry?
7.5k Views Asked by dsimog01 AtThere are 4 best solutions below
On
You can list images (packages) also from within GitHub UI.
List of packages can be found when you simply navigate to a specific GitHub project such as https://github.com/fluxcd/flux2 and in the right panel you can see and click Packages button.
The URL for container GitHub package window is in format https://github.com/<ORGANIZATION>/<PROJECT>/pkgs/container/<PACKAGE>. Here is example URL for Flux2 CLI - https://github.com/fluxcd/flux2/pkgs/container/flux-cli.
From there it is also possible to list all pushed tags.
On
If you published a package to GHCR and want to see it in the browser UI, go to this URL:
https://github.com/username?tab=packages
Just replace 'username' with your GitHub username.
On
You can also do this with GitHub CLI.
Create a classic token with at least the repo, read:packages, read:org permissions. I am not sure why, but the last one was needed for me.
The following generates the same as the previous Octokit answer.
#!/bin/sh
echo "{TOKEN}" | gh auth login --with-token
user=django
containers=$(gh api /users/$user/packages?package_type=container | jq -r .[].name)
for container in $containers; do
versions=$(gh api /users/$user/packages/container/$container/versions)
echo $versions | jq "[
{
container: \"$container\",
name: .[].name,
tags: .[].metadata.container.tags,
}
]"
done
Output:
[
{
"container": "code.djangoproject.com",
"name": "sha256:5ad13961f099c43732cd04638b7504df5c82a993b3c3e29c1e4a0346c04e5e59",
"tags": [
"sha-9ce5a20",
"latest",
"main"
]
},
{
"container": "code.djangoproject.com",
"name": "sha256:5ad13961f099c43732cd04638b7504df5c82a993b3c3e29c1e4a0346c04e5e59",
"tags": [
"sha-125e6f9"
]
},
{
"container": "code.djangoproject.com",
"name": "sha256:5ad13961f099c43732cd04638b7504df5c82a993b3c3e29c1e4a0346c04e5e59",
"tags": [
"sha-5dc9fba"
]
}
]
You can use the GitHub Packages API.
The API requires authentication. You can use a personal token.
With Octokit:
Output: