With exactly the same docker run nginx:alpine
command, you can launch an nginx
container on both arm64 Macs and amd64 Linux servers.
This behavior is (not always but often) based on the fact that the same image name refers to a whole family of images stored in the remote repository.
For instance, if you pull an nginx:alpine
image to your local Docker daemon
and inspect it with docker inspect
,
you'll only see the version of the image corresponding to your current platform:
docker pull ghcr.io/iximiuz/labs/nginx:alpine
docker inspect ghcr.io/iximiuz/labs/nginx:alpine
But if you look at the remote image ghcr.io/iximiuz/labs/nginx:alpine
in the registry,
you'll see that it's actually a list of variants of the nginx
image,
one for every supported platform and architecture,
fronted by a single manifest list (aka image index).
Or, in other words, this is a multi-platform image:
docker manifest inspect ghcr.io/iximiuz/labs/nginx:alpine
The seamless multi- to single-platform conversion that some Docker commands provide can be both a blessing and a curse. It's handy when you simply want to run a container on your local machine, but what if you want to copy a multi-platform image from one repository to another?
The traditional docker pull
, docker tag
, and docker push
sequence
won't work for multi-platform images.
Or, at least, not without additional steps.
In this challenge, you will need to copy the multi-platform ghcr.io/iximiuz/labs/nginx
image from the public GHCR repository
to the playground's private repository registry.iximiuz.com/nginx
.
You need to copy only a single tag - :alpine
,
but make sure to copy all the variants of the image,
so that the docker manifest inspect
command shows similar output for both the original and the new image locations.
For the sake of simplicity, registry.iximiuz.com
is accessible without authentication.
Good luck!
Hint 1 💡
The simple docker pull
, docker tag
, and docker push
sequence won't work out of the box,
but you can try experimenting with different flags of these commands.
For instance, with docker pull --platform linux/arm64
you can pull the arm64 variant of the image
even if you're on an amd64 machine.
Hint 2 💡
The docker manifest inspect
command mentioned in this challenge is not the only one in the docker manifest
family.
Try exploring the other commands listed in the docker manifest --help
output.
Can you create your own multi-platform manifest list from multiple separate single-platform images?
Hint 3 💡
Using a series of docker pull --platform ...
followed by docker manifest create
and docker manifest push
will allow you to copy a multi-platform image from one repository to another.
But it's definitely not the most pleasant way to do it.
Luckily, there are handier tools to copy images between repositories, and they also work for multi-platform images.
Hint 4 💡
There is actually a pretty handy way to copy multi-platform images between repositories using only Docker
and without dealing with the tedious docker manifest
command.
It relies on the docker buildx
subsystem, which is powered by BuildKit, Docker's new default image builder.
Although the command is not very intuitive, it's a good way to copy multi-platform images between repositories without installing additional tools:
docker buildx imagetools create -t <dest> <src>`
Level up your Server Side game — Join 9,000 engineers who receive insightful learning materials straight to their inbox