Skip to content

Instantly share code, notes, and snippets.

@grawert
Last active December 3, 2021 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grawert/540c33043a04e0c5ef54202af85c1d4e to your computer and use it in GitHub Desktop.
Save grawert/540c33043a04e0c5ef54202af85c1d4e to your computer and use it in GitHub Desktop.
skopeo: copy list of images to private registry
#!/bin/bash
# copy image names to docker-images.txt:
# docker image ls --format '{{.Repository}}:{{.Tag}}' > docker-images.txt
TLS_VERIFY=false
REGISTRY=localhost:5000
IMAGES_FILE="${1:-docker-images.txt}"
command -v skopeo &>/dev/null || { echo "skopeo is missing!"; exit 1; }
grep -v '^#\|^$' $IMAGES_FILE | while read -r URL; do
IMAGE=$(echo "$URL" | sed -E 's/^([a-z.A-Z0-9-]+)\/(.+)/\2/')
skopeo copy --dest-tls-verify=$TLS_VERIFY \
docker://$URL \
docker://$REGISTRY/$IMAGE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment