Skip to content

Instantly share code, notes, and snippets.

@brandond
Last active May 11, 2021 14:44
Show Gist options
  • Save brandond/f207af653093690313e615e62e698e5b to your computer and use it in GitHub Desktop.
Save brandond/f207af653093690313e615e62e698e5b to your computer and use it in GitHub Desktop.
Ignorant hack of a script to mirror multiarch images on Docker Hub. Requires docker and jq.
#!/bin/bash
FLAGS=""
SOURCE="docker.io/library"
DEST="docker.io/brandond"
IMAGE="busybox"
TAG="1.32.0-uclibc"
docker buildx imagetools inspect ${SOURCE}/${IMAGE}:${TAG} --raw | \
jq -r '.manifests[] | (.digest + " " + .platform.architecture)' | \
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