In this ultimate image-copying challenge,
your task is to copy not just one, but all the tags of the ghcr.io/iximiuz/labs/nginx
image.
In other words, you must make a full copy of the public GHCR repository
to the playground's private repository at registry.iximiuz.com/third-party/nginx
.
Note that some tags may point to multi-platform builds, so ensure you copy all image variants in those cases.
For simplicity, registry.iximiuz.com
is accessible without authentication.
Good luck!
Hint 1 💡
It's a good idea to start by listing the tags in the source repository so you know exactly what you need to copy.
Unfortunately, docker
doesn't have a command to list tags in a remote repository.
The closest alternative is using docker pull --all-tags
,
but pulling the images to your local machine just to view their tags is a bit excessive.
Can you think of a better way?
Hint 2 💡
Most modern container registries implement the OCI Distribution API, and it's a surprisingly simple API! For instance, to list all the tags of a repository, you just need to send a request like this:
https://<server-address>/v2/<repository>/tags/list.
Here’s what the actual script will look like for GHCR:
REPO=ghcr.io/iximiuz/labs/nginx
TOKEN=$(curl -s https://ghcr.io/token?scope=repository:$REPO:pull | jq -r .token)
curl -s -H "Authorization: Bearer $TOKEN" \
https://ghcr.io/v2/$REPO/tags/list
Hint 3 💡
Does the curl
command from the previous hint seem like too much hassle for a seemingly simple task?
Here are some easier alternatives (though you may need to install some of these tools first):
crane ls $REPO
regctl tag ls $REPO
skopeo list-tags docker://$REPO
Hint 4 💡
Once you know the exact list of tags you need to copy, finishing the challenge is simply a matter of applying the solution from the previous challenge in a loop.
Hint 5 💡
Alright, there might be an easier way to copy all tags from one repository to another.
Remember crane
, regctl
, and skopeo
?
Some of these tools may have a single copy command that loops over all tags and copies them in one go.
Can you find it?
Level up your Server Side game — Join 8,000 engineers who receive insightful learning materials straight to their inbox