Skip to content

Instantly share code, notes, and snippets.

@paralin
Created October 23, 2021 21:21
Show Gist options
  • Save paralin/f29a67230b1f5ad73d72bafb2e4a54d7 to your computer and use it in GitHub Desktop.
Save paralin/f29a67230b1f5ad73d72bafb2e4a54d7 to your computer and use it in GitHub Desktop.
Create a multi-arch docker image from arch tags
#!/bin/bash
set -eo pipefail
pull_image() {
if ! docker inspect $1 ; then
docker pull $1
fi
docker inspect $1
}
IMAGE=$1
if [ -z "$IMAGE" ]; then
echo "set image as argument"
exit 1
fi
ARCH_TAGS=(\
arm \
arm64 \
amd64 \
)
ARCH_IMAGES=("${ARCH_TAGS[@]/#/${IMAGE}:}")
echo "Inspecting / fetching images for ${IMAGE}..."
for aarch in "${ARCH_TAGS[@]}"; do
echo "Getting tag ${aarch}..."
pull_image ${IMAGE}:${aarch}
done
TARGET=${IMAGE}:latest
echo "Creating manifest ${TARGET}..."
docker manifest create --amend $TARGET ${ARCH_IMAGES[@]}
docker manifest push --purge ${TARGET}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment