To push both amd64 and arm64 images to Docker Hub and tag them under the same image tag, you can use Docker's buildx tool to create a multi-architecture manifest. Here's a step-by-step guide:
-
Install and setup buildx (if you haven't already):
docker buildx create --use docker buildx inspect --bootstrap -
Log in to Docker Hub:
docker login -
Load your existing images into buildx:
If you already have the images built locally, you can load them into the buildx builder. Suppose your images are
amd64_image.tarandarm64_image.tar, and you want to push them underyourusername/yourimage:tag.docker load --input amd64_image.tar docker load --input arm64_image.tar -
Tag your images:
Tag your images properly before pushing them.
docker tag <amd64_image_id> yourusername/yourimage:tag-amd64 docker tag <arm64_image_id> yourusername/yourimage:tag-arm64 -
Push the individual architecture images:
Push each architecture-specific image to Docker Hub.
docker push yourusername/yourimage:tag-amd64 docker push yourusername/yourimage:tag-arm64 -
Create and push a multi-architecture manifest:
Create a manifest list that includes both architectures and push it to Docker Hub under the same tag.
docker buildx imagetools create \ --tag yourusername/yourimage:tag \ yourusername/yourimage:tag-amd64 \ yourusername/yourimage:tag-arm64This command creates a manifest list that includes the images for both
amd64andarm64architectures and tags it asyourusername/yourimage:tag.
Now, when you pull yourusername/yourimage:tag, Docker will automatically select the appropriate image for your architecture.