Copy containers between repos
What
This is especially useful when moving from gcr.io
to the new Artifact registry that Google offer.
That's not to say that you can't use this for copying between private repositories (as long as you're authenticated)
How
We can use a tool called gcrane
Install gcrane
This will build and install the package to your $PATH
List images
We should see something similar to the below
index.docker.io/userbradley/searchsploit:alpine-0.0.1
index.docker.io/userbradley/searchsploit:alpine-0.0.2
index.docker.io/userbradley/searchsploit:alpine-base
index.docker.io/userbradley/searchsploit:ubuntu-0.0.1
index.docker.io/userbradley/searchsploit:ubuntu-1
Copy all images to AR
External sources
Gcrane not working
Somtimes after running the command, it returns with nothing.
I cant explain why it does this, but it's annoying.
Create a file with all the images
Make sure to remove the index.docker.io/reponame/container
at the start of the image, or it breaks
Create a script to copy them one after another
## copy.sh
#!/bin/bash
images=$(cat images.txt)
for img in ${images}
do
gcrane cp userbradley/searchsploit:${img} europe-west2.pkg.dev/bradley/searchsploit/searchsploit:${img}
done
The reason we specify the image name in the script is because when I was running it, it was copying the containers but not the tags
Assign Execute Permissions
Run the copy job
Note
You can replace europe-west2...
with any Docker compliant repo. Only tested with GCR and GAR
footnotes
If you are not copying to GAR
You may want to look at the below
Want to make this site better? Open a PR or help fund hosting costs