Run x86 (Intel) and ARM based images on Apple Silicon (M1) Macs?

For my home network, I am looking at a new server unit, to run the various containers and other things. My previous setup used a Ubuntu x86 instance. I know the majority of the images I use are x86 based and have not really looked much into the ARM world. Until now…

Being an Apple customer, I am wondering if use a Mac Mini M1, do ALL Docker images run as expected? Does this happen via the Rosetta 2 framework? Or some other abstraction layer? What, if anything, needs to change? Can you dual-run the Intel and M1 versions of Docker Desktop on the same unit?

You can run ARM or Intel Docker containers on the Apple M1 Mac with Docker Desktop for Mac M1. I do it all the time. The default, of course, is to run the ARM version but if you use the --platform linux/amd64 parameter Docker will run the Intel version for you.

You can try it with one of my images that I’ve built to run Vagrant with Docker as a provider on Apple M1 Silicon:

docker run --rm -it --platform linux/amd64 rofrano/vagrant-provider:debian bash

That will drop you into a bash shell in an amd64 container.

# uname -a
Linux 694817f598fe 5.10.47-linuxkit #1 SMP PREEMPT Sat Jul 3 21:50:16 UTC 2021 x86_64 GNU/Linux

BTW, I absolutely love my M1 Mac mini for development work. It is blazing fast! I highly recommend getting one.

If you want more info on how I built that image I documented it in this article:
Developing on Apple M1 Silicon with Virtual Environments

Hope that helps.

5 Likes

Hey there! This helped me tremendously, I am developing on my M1 Max MacBook however I ran into an issue when executing. I have a Python docker container running x86_64 (I needed this to be able to use a library that requires the x86_64 architecture) and my code is working. However I ran into issues as i executed my script stating MemoryError this prompted me to leun lscpu within my container when I found that my CPU architecture was set as x86_64 but my CPU op-mode was only 32-bit, for some reason on some level I am only running as 32-bit which restricts the amount of RAM my container can consume I believe

At least it does not work for me
docker run -p 80:8080 swaggerapi/swagger-ui --platform linux/amd64
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-entrypoint.sh: exec: line 38: illegal option –

That’s an other issue. You made a very common mistake and used --platform linux/amd64 after the image name. Everything after the image name is the parameter of the entrypoint. It will be the part of the command running inside the container. This is why the entrypoint got an “illegal option”. This is the right syntax:

docker run -p 80:8080 --platform linux/amd64 swaggerapi/swagger-ui 

I also started to deal with the same problem when I’d moved to MacBook M1.
I found the platform: linux/arm64/v8 works properly.

Hi,
It seems to work with some specific images.
For example this one does not work:
docker run --platform linux/amd64 foundationdb/foundationdb:6.3.12

Output logs are very limited:

Starting FDB server on 172.17.0.2:4500
Error: Disk i/o operation failed