How to get a list of tags from a private GitLab Docker Registry with curl

We tried to mirror the Docker images (all tags) of the private GitLab Docker Registry from a project we sourced to an external company.

This has been a real struggle, because I haven’t done this before and I had no idea how to get this thing going.


Instead of placeholders, we assume that our GitLab is available at and our GitLab Docker Container Registry is availabe at

Anyway, this is how you do it in bash:

Use a token instead of a password

Log into Gitlab, then head over to your settings page and click on Access Tokens


Create an access token with read_registry scope. This grants read-only access to container registry images on private projects.

Encode username and token

To get the bearer token, we have to authenticate and this is done with our username (gorillamoe) and our access_token (for_the-LulZ).

It would be way too easy, if we could just pass them as they are; we have to base64-encode them like so:

basic_auth_encoded=$(echo "gorillamoe:for_the-LulZ" | base64 -)

Then echoing should give us Z29yaWxsYS5tb2U6Zm9yX3RoZS1MdWxaCg==:

echo $basic_auth_encoded
# should be Z29yaWxsYS5tb2U6Zm9yX3RoZS1MdWxaCg==

Request bearer token

You need to also pass it the path of the docker image. In dockerhub-land there is only username/image-name (e.g. would be gorillamoe/seefu), but in GitLab there is no such limitation. It could be anything.

For simplicitys sake, let’s assume the docker image URL is, then the path is foo/bar/baz/walialu.

Now that we have our credentials encoded, we request a bearer token:

bearer_token=$(curl -s -X GET -H "Authorization: Basic $basic_auth_encoded" "$docker_image_path:push,pull" | jq -r .token)

Request tags list

Now, that we have the bearer token, we can request the tags:

tags=$(curl -s -X GET -H "Authorization: Bearer $bearer_token" "$docker_image_path/tags/list" | jq -rc .tags[])

Iterate over each tag in list

And iterate over all them tags is easy as pie:

echo "Tags for $docker_image_path"
for tag in $tags; do
	echo "$tag"

That’s it!