Is there a way to get tags of a docker image on github container registry via curl or gh command?
curl
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${GH_TOKEN}"
-H "X-GitHub-Api-Version: 2022-11-28"
https://api.github.com/orgs/${ORG}/packages/container/${CONTAINER_IMG}
I have tried above but it does not give me docker tags for the iamge.
I am expecting to get the docker tags of ghcr.io containers.
2
Answers
If your environment allows installing software, it is easier to use
skopeo
. It is available by default on GitHub Action’s Linux environment, and in most distros package repos.With curl, the commands look like:
Note that you need to provide a login to the token command (in the
-u
option). Thetags/list
API is a standard registry API, not specific to GHCR, but auth will have different hosts for their token server, or just use basic auth without a token.Tools that simplify registry APIs like this include Google’s crane, RedHat’s skopeo, or my own regclient.