-->

DEVOPSZONES

  • Recent blogs

    How to convert amd64 docker image to multi-arch

     To convert an existing amd64 Docker image into a multi-architecture (multiarch) image that supports platforms like linux/amd64 and linux/arm64, you need to use docker buildx.


    ✅ Steps to Create a Multi-Arch Docker Image

    1. Enable experimental features and create a buildx builder

    docker buildx create --use --name multiarch-builder
    docker buildx inspect --bootstrap
    

    ✅ This ensures you can build images for multiple platforms in one go.


    2. Build and push a multiarch image

    If you're pushing to a registry (e.g., Docker Hub or ECR):

    docker buildx build \
      --platform linux/amd64,linux/arm64 \
      -t <your-registry>/<image-name>:<tag> \
      --push .
    

    Example:

    docker buildx build \
      --platform linux/amd64,linux/arm64 \
      -t myuser/myapp:latest \
      --push .
    

    🧠 --push is required for multiarch images since they’re built in a remote context.


    3. (Optional) Test locally

    To load for local testing (only works for one platform at a time):

    docker buildx build --platform linux/amd64 -t myimage:local --load .
    

    ✅ Verify Multi-Arch Support

    After building and pushing, inspect the image:

    docker buildx imagetools inspect <your-registry>/<image-name>:<tag>
    

    Expected output should include something like:

    "manifests": [
      {
        "platform": {
          "architecture": "amd64",
          "os": "linux"
        },
        ...
      },
      {
        "platform": {
          "architecture": "arm64",
          "os": "linux"
        },
        ...
      }
    ]
    

    📌 Notes

    • You must be logged into your registry (e.g., Docker Hub) to push.

    • You must use buildx and --push to generate multi-platform manifests.

    • The Dockerfile itself must not include architecture-specific binaries unless you're handling them with conditional logic (e.g., downloading binaries for the right TARGETARCH).


    No comments