# Docker pulling in wrong architecture

**URL:** <https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989>\
**Category:** General\
**Created:** [September 15, 2022, 8:55am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989 "2022-09-15T08:55:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [September 15, 2022, 8:55am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/1 "2022-09-15T08:55:25Z")

</div>

I’ve managed to build a multi-arch image, but when I do Docker pull on my M1 Mac, it still pulls in the amd64 version instead of the arm64 one.

I didn’t build with `buildx` because I have architecture-specific binaries to include in my image. So I have two Docker files, create two images which I push. Then I create a manifest that I annotate so that it includes both images:

```auto
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1579,
         "digest": "sha256:2c...",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1579,
         "digest": "sha256:7c...",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}

```

But when I do `docker pull` of this image/manifest on my M1, it still pulls in the amd64 version. I can check this by running `docker inspect` on the pulled image.

I thought Docker would automatically download the image that fits my architecture? Or is something still wrong with the manifest?

---

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [September 15, 2022, 9:07am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/2 "2022-09-15T09:07:56Z")

</div>

Ok, on further investigation, it seems the contents of the image are correct (it includes the statements to download the correct native binary). But the `docker inspect` command still says it’s made for amd64. So I’m thinking it’s something with the way the image was created or the way it was pushed to the registry.

---

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [September 15, 2022, 10:39am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/3 "2022-09-15T10:39:02Z")

</div>

It seems I have to build the images with `buildx` instead of just plain `docker build`.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 16, 2022, 7:52pm UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/4 "2022-09-16T19:52:14Z")

</div>

> [@petermorlion](#):
>
> create two images which I push.

How did you push the images? Using different tags for both images and a third tag for the multi-arch image?  
I guess you folloed these instructions:

> **[docker manifest](https://docs.docker.com/engine/reference/commandline/manifest/)**

As you suspected, `docker pull` should pull the image with the matching architecture unless you override with the `--platform` option. If it didn’t work for you, then you probably did not have that architecture which can be because of using the same tag for both images. Althought I am not sure how you could have create the manifest that way, so there is a good chance that I am wrong.

---

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [September 19, 2022, 2:55pm UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/5 "2022-09-19T14:55:11Z")

</div>

We basically did what you explain. But our thinking now it that we need to build with `buildx` and have some emulator installed. We’re still not there yet, but once we find out how to do this, I’ll post the solution here.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 19, 2022, 6:55pm UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/6 "2022-09-19T18:55:56Z")

</div>

Docker Desktop has a built-in emulator. You don’t need buildx for that, but to be honest, when I wanted to create my first multi-arch image, I also started with docker manifest and ended up using buildx because it was easier for me and worked perfectly.

---

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [September 20, 2022, 9:54am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/7 "2022-09-20T09:54:59Z")

</div>

Except, I don’t have a single Dockerfile. Because we have architecture-specific binaries that must be included in the container, we have separate Dockerfiles. So I can’t just use `buildx` and tell it to build for two different architectures based on a single file.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 20, 2022, 10:00am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/8 "2022-09-20T10:00:45Z")

</div>

Architecture-specific binaries can be handled in one Dockerfile if that helps:

> **[Building Multi-CPU Architecture Docker Images for ARM and x86 (1): The Basics](https://itnext.io/building-multi-cpu-architecture-docker-images-for-arm-and-x86-1-the-basics-2fa97869a99b)**
>
> Building Multi-Arch Docker Images on Your Local Machine

The platform variables are automatically set so you can use those to copy or download different binaries into each image.

---

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [September 21, 2022, 12:59pm UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/9 "2022-09-21T12:59:55Z")

</div>

Thanks for the link! We’ve currently solved it by running the following commands in our Jenkins build:

```auto
# install emulator
docker run --privileged --rm tonistiigi/binfmt --install linux/arm64,linux/amd64
# create builder
docker buildx create --name multiarch --driver docker-container --platform linux/amd64,linux/arm64 --use
docker buildx inspect --bootstrap

# create images
docker buildx build -f Dockerfile.amd64 -t our-repo.com/image-amd64 --platform=linux/amd64 . --push
docker buildx build -f Dockerfile.arm64 -t our-repo.com/image-arm64 --platform=linux/arm64 . --push

# pull locally, because the --push flag previously ensured the image doesn't exist locally
docker pull our-repo.com/image-amd64
docker pull our-repo.com/image-arm64

# create, annotate and push manifest
docker manifest create our-repo.com/image:latest --amend our-repo.com/image-amd64:latest --amend our-repo.com/image-arm64:latest
docker manifest annotate rour-repo.com/image:latest our-repo.com/image-amd64:latest --os linux --arch amd64
docker manifest annotate our-repo.com/image:latest our-repo.com/image-arm64:latest --os linux --arch arm64
docker manifest push our-repo.com/image:latest

```

This now works for us, it seems.

---

<div class="post-metadata">

**Author:** ![petermorlion](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/petermorlion/32/36405_2.png) [@petermorlion](https://forums.docker.com/u/petermorlion)\
**Post date:** [October 13, 2022, 6:39am UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/10 "2022-10-13T06:39:06Z")

</div>

For those coming here for help, I must say we didn’t really get it working. The built images never ran correctly. So what we did was base our image off a multiplatform base image (Java) that already contained the correct binary. Sorry.

Also, thanks @rimelek , the post you mentioned did help. We managed to use multi-stage builds and/or the TARGETOS/TARGETARCH to differentiate.

---

<div class="post-metadata">

**Author:** ![kaylors](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/kaylors/32/44676_2.png) [@kaylors](https://forums.docker.com/u/kaylors)\
**Post date:** [January 11, 2024, 7:30pm UTC](https://forums.docker.com/t/docker-pulling-in-wrong-architecture/128989/11 "2024-01-11T19:30:32Z")

</div>

You’re one of those rare people on the internet who actually posted their experience as you went along. Ive read so many posts where it ended with: “figured it out, bye” that this was a breath of fresh air. Thank you!
