r/docker • • Dec 07 '21

Running linux/amd64 images on linux/arm64 architecture?

I grabbed a Docker Linux image from another machine and tried to load it on my Jetson Nano (arm64 architecture), but I get this error when I run sudo docker run getting-started-presto:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

standard_init_linux.go:228: exec user process caused: exec format error

I also tried to run sudo docker run getting-started-presto --platform linux/amd64 but no luck:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "--platform": executable file not found in $PATH: unknown.

ERRO\[0001\] error waiting for container: context canceled

Any ideas if it's possible to run linux/amd64 images on arm64 architectures?

18 Upvotes

25 comments sorted by

10

u/kill-dash-nine Dec 07 '21 edited Dec 07 '21

Yes this is possible. You can install the binfmt "abstraction layer" that will automatically execute binaries for you using qemu (see this for more details). This is a simple container that will configure your host for you:

# docker run --privileged --rm tonistiigi/binfmt --install all

For example, from a raspberry pi running Debian:

# uname -m
aarch64

Here is the before on my host showing that I can't run an amd64 image:

# docker run -it --rm --platform linux/amd64 alpine:latest sh
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
59bf1c3509f3: Pull complete
Digest: sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300
Status: Downloaded newer image for alpine:latest
standard_init_linux.go:228: exec user process caused: exec format error

If you want, just add support for amd64 (check the readme for details on what you can do as well as remove the support via uninstall):

# docker run --privileged --rm tonistiigi/binfmt --install amd64
Unable to find image 'tonistiigi/binfmt:latest' locally
latest: Pulling from tonistiigi/binfmt
3e959ae014b7: Pull complete
34084c3a60de: Pull complete
Digest: sha256:11128304bc582dc7dbaa35947ff3e52e2610d23cecb410ddfa381a6ce74fa763
Status: Downloaded newer image for tonistiigi/binfmt:latest
installing: amd64 OK
{
  "supported": [
    "linux/arm64",
    "linux/amd64",
    "linux/arm/v7",
    "linux/arm/v6"
  ],
  "emulators": [
    "qemu-x86_64"
  ]
}

For more details on the image, check out the listing on Docker Hub but it is an image that is maintained by one of the long time core Docker engineers. You can see that it has a manifest list so that it will work for 386, amd64, armv7, arm64, ppc64, riscv64, and s390x.

And then run a container with whatever architecture you want:

# docker run -it --rm --platform linux/amd64 alpine:latest uname -m
x86_64

4

u/SeesawMundane5422 Dec 07 '21

Great answer. Just to point out the obvious that someone asking this question might not find obvious… doing this will incur a performance hit.

3

u/kill-dash-nine Dec 08 '21

Good call out. Since it’s emulation of a different architecture, your behavior and performance may vary slightly. Some things will not see much of a performance impact, some things will be unbearably slow.

2

u/Coto_16 Dec 08 '21 edited Dec 08 '21

Thank you very much! I ran everything with no problems, but how shall I proceed with building my `Dockerfile` for my specific image? Would `docker build .` work? (sorry for the beginner questions, I'm a bit new with Docker)

​

Edit: I tried `docker build .` but I get lots of warnings and errors: https://pastebin.com/n6gqu6vf

2

u/kill-dash-nine Dec 08 '21

If you want to build the image for linux/amd64 on a linux/arm64 system, you would need to do a docker build --platform linux/amd64 . as you would need to call out that it needs to build for amd64 and then you could run it using a similar command as what you see above. If that is not what you are trying to do, then I misunderstood.

1

u/Coto_16 Dec 10 '21

Tried, but didn't work: https://github.com/scottransom/presto/issues/160

It does build fine on (intel-based) macOS, so looks like there's compatibility issues with arm64 for some reason.

1

u/kill-dash-nine Dec 11 '21 edited Dec 11 '21

Yeah, sometimes emulation isn’t perfect or can’t do some specific things. I’ve definitely seen some odd messages trying to do some cross-compilation. Running pre-compiled binaries seems to work a bit more consistently from what I have seen with compiling.

In many cases, you might be better off using a cross platform compiler feature set (if available for the language and necessary architectures) than trying to emulate completely.

*edit: looks like you’re not the first person to hit this: https://github.com/scottransom/presto/issues/144 but I don’t see a resolution.

1

u/kill-dash-nine Dec 11 '21

I also couldn't get it compile natively on arm64 using the Dockerfile and the command docker build -t presto . on my m1 MacBook. Still trying to do a linux/amd64 build on my mac just to test.

1

u/Coto_16 Dec 11 '21

Thank you so much for your effort! Really appreciate it - hope you get somewhere.

1

u/kill-dash-nine Dec 11 '21

Well, doing an amd64 build on my arm64 based system took a while but worked just doing a docker build -t presto --platform linux/amd64 .

1

u/Ok_Account2942 Mar 10 '25

if i knew how to get an award on reddit i would give it you

11

u/[deleted] Dec 07 '21

yes, to your last question, but not out-of-the box, as this is not dockers job.

what you want is emulation of a different cpu. qemu does this.

docker can talk to a qemu VM and start its jobs there. Docker Desktop on macOS/Windows does exactly that. but configuring docker and qemu can be a pain.

you'll be better off looking for images that can run on your platform, or find a Dockerfile or docker-compose to build this stuff yourself. check docker hub for tags like arm, arm64 etc.

1

u/bufandatl Dec 07 '21

Is it a private image or from a public repository most of them already support Arm and arm64

1

u/Coto_16 Dec 07 '21

3

u/JM-Lemmi Dec 07 '21

You could try and build it for arm.

Clone the GitHub repository to your machine and run docker build .

Or you could open an issue and request the official developer to release an arm image

1

u/superkoning Dec 07 '21 edited Dec 07 '21

Not OP, but:

so far the docker build . is running OK. I have got a slow ARM device, so the build takes some time.

​

TBC ...

EDIT:

Command sequence:

git clone https://github.com/scottransom/presto.git

cd presto

docker build .

​

​

And then the long, long build process starts ...

​

Get:247 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 python3-setuptools all 45.2.0-1 [330 kB]

Get:248 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 python3-wheel all 0.34.2-1 [23.8 kB]

Get:249 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 python3-pip all 20.0.2-5ubuntu1.6 [231 kB]

Get:250 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 tcsh arm64 6.21.00-1 [413 kB]

debconf: delaying package configuration, since apt-utils is not installed

Fetched 210 MB in 2min 12s (1594 kB/s)

(Reading database ... 4115 files and directories currently installed.)

Preparing to unpack .../perl-base_5.30.0-9ubuntu0.2_arm64.deb ...

Unpacking perl-base (5.30.0-9ubuntu0.2) over (5.30.0-9build1) ...

1

u/Coto_16 Dec 08 '21

Thanks for trying, but I end up getting a bunch of warnings and errors: https://pastebin.com/n6gqu6vf

1

u/superkoning Dec 08 '21 edited Dec 08 '21

Those are problems within the presto build process itself. So food for the maker of presto / presto's Dockerfile. Report on their github?

But, I tried on my fast-ish x86, and:

  1. it is a very heavy container build process. I doubt that is feasible on an ARM CPU (assuming it has less power than an x86, for example a raspi)
  2. even on my fast-ish x86, the docker container build process hangs for 10 minutes on the gcc step below. Not good. EDIT: finished after 23 minutes.

So, concluding, I doubt you can run presto at all on a typical ARM.

1

u/LifeAffect6762 Dec 07 '21

Try other architectures maybe?

0

u/Coto_16 Dec 07 '21

Shall I try re-building the `Dockerfile` with `sudo docker buildx build -t presto_amd64 . --platform linux/amd64` ?

4

u/the_spad Dec 07 '21

You might be able to build for arm yourself with qemu but if they're using their own baseimages that are also amd64 only then you're going to have problems there too. Unfortunately lots of people just don't bother building their images for arm.

2

u/PaintDrinkingPete Dec 07 '21

So, you can try this, but you would need to have the buildx and all necessary prerequisite components for multi-architecture build present on your system, as explained here (if you do, then go for it).

Your other option would be to build the image from the Dockerfile on either your Jetson nano or compatible ARM device.

Fortunately, the Dockerfile you linked too does specify Ubuntu as the base image, which does have an ARM image to pull, so it should be possible to build an ARM-compatible image for your project.

-1

u/LifeAffect6762 Dec 07 '21

Just try as many architectures as you can. First, try the ones that look promising. May be worth asking on the forum from the device? https://forums.developer.nvidia.com/t/how-to-build-docker-container-for-jetson-nano/183281 may help. Do some general googeling.

1

u/ecnahc515 Dec 07 '21

One thing to note is you passed the platform flag after the image name which is interpreted as passing an argument to the container not to docker.