Skip to content

Instantly share code, notes, and snippets.

@djbender
Last active February 11, 2026 18:34
Show Gist options
  • Select an option

  • Save djbender/1d99942fed51d96279d86c987db77df3 to your computer and use it in GitHub Desktop.

Select an option

Save djbender/1d99942fed51d96279d86c987db77df3 to your computer and use it in GitHub Desktop.
Demo multi-arch Docker manifest merge with a local registry
#!/usr/bin/env bash
set -euo pipefail
REGISTRY="${REGISTRY:-localhost:5000}"
IMAGE="${IMAGE:-core}"
VERSION="${VERSION:-noble}"
TAG="${TAG:-test}"
LOGDIR=$(mktemp -d)
RESULT="FAILED"
cleanup() {
echo "==> Stopping local registry"
docker stop registry &>/dev/null || true
rm -rf "$LOGDIR"
echo "==> ${RESULT}"
}
trap cleanup EXIT
echo "==> Starting local registry"
if docker ps -a --format '{{.Names}}' | grep -q '^registry$'; then
docker start registry &>/dev/null
else
docker run -d -p 5000:5000 --name registry registry:2 &>/dev/null
fi
sleep 2
echo "==> Building ${IMAGE}:${VERSION} for both platforms in parallel"
echo " Logs: ${LOGDIR}/{amd64,arm64}.log"
docker buildx build --platform linux/amd64 -t "${REGISTRY}/${IMAGE}:${TAG}-amd64" --push "${IMAGE}/${VERSION}" \
> "${LOGDIR}/amd64.log" 2>&1 &
pid_amd64=$!
docker buildx build --platform linux/arm64 -t "${REGISTRY}/${IMAGE}:${TAG}-arm64" --push "${IMAGE}/${VERSION}" \
> "${LOGDIR}/arm64.log" 2>&1 &
pid_arm64=$!
echo "==> Waiting for builds (amd64: $pid_amd64, arm64: $pid_arm64)"
amd64_ok=0; arm64_ok=0
wait $pid_amd64 && amd64_ok=1 || true
wait $pid_arm64 && arm64_ok=1 || true
if [[ $amd64_ok -eq 0 ]]; then
echo "==> amd64 build failed:"
tail -20 "${LOGDIR}/amd64.log"
fi
if [[ $arm64_ok -eq 0 ]]; then
echo "==> arm64 build failed:"
tail -20 "${LOGDIR}/arm64.log"
fi
if [[ $amd64_ok -eq 0 || $arm64_ok -eq 0 ]]; then
echo "==> FAILED"
exit 1
fi
echo "==> Creating multi-arch manifest"
docker buildx imagetools create -t "${REGISTRY}/${IMAGE}:${TAG}" \
"${REGISTRY}/${IMAGE}:${TAG}-amd64" \
"${REGISTRY}/${IMAGE}:${TAG}-arm64"
echo "==> Inspecting manifest"
docker buildx imagetools inspect "${REGISTRY}/${IMAGE}:${TAG}"
RESULT="SUCCESS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment