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.

4 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

1 Like

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.

1 Like

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

Any tips for docker-images/OracleDatabase at main · oracle/docker-images · GitHub ?? As Oracle Linux is not supporting AARM.
Thanks

It looks like the base images (Oracle Linux) support arm64/v8: https://hub.docker.com/_/oraclelinux/tags

Since you referred to the GitHub repository, you should be able to build an image for this architecture. If there is any architecture dependent instruction in the Dockerfiles, you can still use the platform option as mentioned in this topic earlier, exxcept that you probably need --platform linux/amd64. I wouldn’t use that in production but it could be good for testing.

update:

I missed this statement. Now I am not sure I understood you since they do support ARM. Or is there an architecture called AARM? Wasn’t that a typo?

Found the acronym on some sites AARM = Apple ARM :slight_smile:

Since my message, I have added the —platform
But it seems that the 16go M1 have been given is short in memory for running a container based on the image. I am continuing my tests

Since containers on Mac are running in a Linux virtual machine, you don’t need any special “apple ARM” just the usual linux/arm64

Hey @rofrano , does this run on emulation? I’m wondering if that slows down performance a bit & it’s just meant for testing?

Yes, if you change the CPU architecture, the container has to be emulated. And yes, it can affect performance and sometimes it doesn’t work at all.

Docker Desktop is for development and emulation helps you so you don’t have to buy another computer for the other architecture. If you want to run an application in production, run the Linux container on Linux on the right architecture. Depedning on what the application does, it could run emulated in production, but I wouldn’t do that normally.

Hi @iarc13 , As @rimelek pointed out, there is a slight performance hit because Intel images will run in emulation using QEMU on an ARM based Apple Silicon Mac. It’s usually not a problem for developing.