Mongo 5+ on Apple M1 laptops via Docker

I just upgraded my development machine to an M1 MacBook Pro, and immediately discovered that my mongodb docker containers weren’t working. I noticed that there isn’t yet a build of mongodb for the M1, and I found the relevant ticket for the upgrade which doesn’t look like it’ll be addressed any time soon (backlogged P3). This would be fine if mongodb ran under Rosetta, but with v5 an AVX requirement was introduced. Rosetta does not simulate AVX.

I find myself stuck. Do I have to roll back to mongo4? Is there any way to get an M1 build prioritised?

@Michael_Townsend - Let’s continue the discussion from https://jira.mongodb.org/browse/SERVER-42427 here.

In your environment, which binaries are being run within the Docker container? Is Docker compiled natively for M1 or is it itself running under Rosetta 2? I suspect that what may be happening is that Docker is trying to run the x86_64 linux MongoDB 5.0 binaries inside the Docker container, and those do indeed require AVX, which Rosetta 2 doesn’t emulate.

But I’m puzzled why Docker running on an M1 would be emulating an x86 environment. Shouldn’t it be running an ARM linux, and then using the ARM linux MongoDB in that, etc.?

1 Like

Hello @Michael_Townsend!

Would you by chance be interested in trying to run MongoDB 5.0 Natively on your M1 Mac?

I am sorry for any frustration this has all caused you, but I may have an acceptable work around for the time being.

The way to install 5.0 Natively without Docker on an M1 Mac:

  • brew tap mongodb/brew
  • brew install mongodb-community@5.0
  • brew services start mongodb-community

To check and verify that it is running:

  • brew services list

If you have you have any issues with this work around, please let me know. As I would be happy to help you situate this. However, if you must have MongoDB 5.0 within a Docker container for work requirements that’s is completely understandable. I am merely giving you another option to use MongoDB 5.0 on your M1 Mac while compatibility developments using Docker are sorted out.

I would also love to hear about your applications stack and use case(s) for MongoDB on your M1 Mac like my colleague Andrew would.

Anything else that we can help you with in the meantime, please let us know.

Regards,

Garrett

Hi Garrett

I would be happy to try out MongoDB 5.0 natively (without Docker) on my Apple M1 Max running the latest macOS Monterey.

When you say “natively” due you mean true native or still via Rosetta 2 ?

regards
Matt

Welcome to the MongoDB Community Forums @Matthew_Donaldson!

At the moment, running natively on Apple M1 is referring to using Rosetta 2 without Docker (for example, installing the macOS x86_64 binaries via brew). The macOS packages are working fine for me on M1 with Rosetta 2 installed.

This discussion was originally about someone trying to run the Linux x86_64 binaries in Docker on M1, which will be problematic because of the requirement for AVX support in MongoDB 5.0 packages for Linux x86_64. The solution for the original question would be to either install MongoDB 4.4 packages on Linux (since those are not optimised for AVX) or to build MongoDB 5.x from source with an older x86_64 CPU architecture target.

Building the MongoDB server with ARM64/aarch64 support for MacOS (SERVER-50115) is currently blocked pending resolution of a SpiderMonkey JavaScript engine upgrade (SERVER-42427).

Regards,
Stennie

1 Like

Hello Everyone!

Yesterday I found this forum as was sad to see that it didn’t seem possible to run Mongo 4.9+ with Docker. However I managed to get it work! I wrote a post on Stack Overflow and am actually right now trying to figure out why it does in fact work. If you’re having this issue hopefully this thread could be of use.