Skip to content

Instantly share code, notes, and snippets.

@bdimcheff
Forked from brandond/mirror-image.sh
Last active May 11, 2021 14:42
Show Gist options
  • Save bdimcheff/3974944d40c5ee94fec2d7232b877211 to your computer and use it in GitHub Desktop.
Save bdimcheff/3974944d40c5ee94fec2d7232b877211 to your computer and use it in GitHub Desktop.
mirror go images
#!/bin/bash
FLAGS=""
SOURCE="docker.io/library"
DEST="docker.io/bdimcheff"
IMAGE="golang"
TAG="1.16.4-alpine"
docker buildx imagetools inspect ${SOURCE}/${IMAGE}:${TAG} --raw | \
jq -r '.manifests[] | (.digest + " " + .platform.architecture + .platform.variant)' | \
while read DIGEST ARCH; do
docker pull ${SOURCE}/${IMAGE}:${TAG}@${DIGEST}
docker tag ${SOURCE}/${IMAGE}:${TAG}@${DIGEST} ${DEST}/${IMAGE}:${TAG}-${ARCH}
docker push ${DEST}/${IMAGE}:${TAG}-${ARCH}
docker buildx imagetools create ${FLAGS} --tag ${DEST}/${IMAGE}:${TAG} ${DEST}/${IMAGE}:${TAG}-${ARCH};
docker buildx imagetools create ${FLAGS} --tag ${DEST}/${IMAGE}:latest ${DEST}/${IMAGE}:${TAG}-${ARCH};
FLAGS="--append"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment