The Ops Community ⚙️

Joseph D. Marhee
Joseph D. Marhee

Posted on

Exporting images with Containerd CLI (ctr)

I recently found that a Docker image I use as a part of one of my Helm charts was no longer available on DockerHub, and I hadn't mirrored it in another location. It was running in a K3s cluster, meaning I couldn't docker tag original-maintainer/image:tag me/image:tag it and push to the Hub myself back on my local machine, which was running the Docker CLI.

First, logging into a node with the image on it, I ran the following:

ctr -n k8s.io images export bind9:9.11.tar docker.io/internetsystemsconsortium/bind9:9.11 --platform linux/amd64
Enter fullscreen mode Exit fullscreen mode

which exported the image to a tarball. This is similar to docker image save.

Then, pulling it down to my Docker CLI machines:

scp jdmarhee@192.168.0.60:bind9:9.11.tar .
Enter fullscreen mode Exit fullscreen mode

I then load the image from the tarball:

 docker image load --input bind9\:9.11.tar
Enter fullscreen mode Exit fullscreen mode

which returns the original tag for the image (internetsystemsconsortium/bind9:9.11) so I can re-tag it and push:

docker image tag internetsystemsconsortium/bind9:9.11 jmarhee/bind9:9.11

docker push jmarhee/bind9:9.11
Enter fullscreen mode Exit fullscreen mode

Now this image is available on Docker Hub for my (and your) new clusters to access.

Top comments (0)