Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/mongodb] Mongodb doesn't run on M1 Mac #40947

Open
tclasen opened this issue Jul 13, 2023 · 36 comments
Open

[bitnami/mongodb] Mongodb doesn't run on M1 Mac #40947

tclasen opened this issue Jul 13, 2023 · 36 comments
Assignees
Labels
mongodb on-hold Issues or Pull Requests with this label will never be considered stale tech-issues The user has a technical issue about an application

Comments

@tclasen
Copy link

tclasen commented Jul 13, 2023

Name and Version

bitnami/mongodb:5.0.10-debian-11-r3

What architecture are you using?

arm64

What steps will reproduce the bug?

I'm actually trying to run the Bitnami helm chart for Mongodb running in minikube on a M1 Mac. But I can replicate the problem with: docker run --rm -it docker.io/bitnami/mongodb:5.0.10-debian-11-r3

What is the expected behavior?

I would like to see aarch64 (arm64) images published to dockerhub for 5.0.10 and newer versions of Mongo.

What do you see instead?

docker run --rm -it docker.io/bitnami/mongodb:5.0.10-debian-11-r3

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
mongodb 20:51:20.14
mongodb 20:51:20.17 Welcome to the Bitnami mongodb container
mongodb 20:51:20.18 Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb 20:51:20.20 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb 20:51:20.22
mongodb 20:51:20.24 INFO  ==> ** Starting MongoDB setup **
mongodb 20:51:20.35 INFO  ==> Validating settings in MONGODB_* env vars...

It hangs on this step forever. In the k8s template, the pod is restarted due to being detected as stuck and timed out.

I've tried to build these myself using the bitnami/containers repo, but I get the following error:

0.752 mongodb-shell-1.10.1-0-linux-arm64-debian-11.tar.gz: OK
1.540 yq-4.34.2-0-linux-arm64-debian-11.tar.gz: OK
1.697 wait-for-port-1.0.6-9-linux-arm64-debian-11.tar.gz: OK
1.814 render-template-1.0.5-7-linux-arm64-debian-11.tar.gz: OK
2.014 sha256sum: mongodb-5.0.18-1-linux-arm64-debian-11.tar.gz.sha256: no properly formatted SHA256 checksum lines found
Dockerfile:26

Additional information

According to the mongo forums the x86 binary requires the AVX CPU flag which isn't provided by the Rosetta x86 emulator, meaning it is expected that the x86 version of mongo would never be able to run on the aarch64 (arm64) architecture of a M1 Mac. https://www.mongodb.com/community/forums/t/mongodb-docker-container-not-starting-properly/160540

@tclasen tclasen added the tech-issues The user has a technical issue about an application label Jul 13, 2023
@github-actions github-actions bot added the triage Triage is needed label Jul 13, 2023
@debdutdeb
Copy link

debdutdeb commented Jul 14, 2023

I was just going to open this exact ticket myself. mongo:5.0 arm64 image runs fine on m1/m2 for example.

@javsalgar is there any way I can help? I was looking at the existing workflows thinking about opening a pr, but doesn't seem like the build/release part of the automation is on github.

Having this fixed would be quite valuable for us at @RocketChat

@debdutdeb
Copy link

@javsalgar javsalgar changed the title Mongodb doesn't run on M1 Mac [bitnami/mongodb] Mongodb doesn't run on M1 Mac Jul 14, 2023
@javsalgar
Copy link
Contributor

Hi!

I'm afraid we currently don't have support for Debian 11 ARM. As soon as we add support for this, we will notify the community

@github-actions github-actions bot added on-hold Issues or Pull Requests with this label will never be considered stale and removed triage Triage is needed labels Jul 14, 2023
@MargaretKrutikova
Copy link

We have been using this unofficial mirror of bitnami/mongodb image that supports arm64 https://hub.docker.com/r/zcube/bitnami-compat-mongodb. In case someone else finds it useful.

@github-actions github-actions bot added triage Triage is needed and removed on-hold Issues or Pull Requests with this label will never be considered stale labels Aug 7, 2023
@saintdle
Copy link

saintdle commented Aug 8, 2023

We have been using this unofficial mirror of bitnami/mongodb image that supports arm64 https://hub.docker.com/r/zcube/bitnami-compat-mongodb. In case someone else finds it useful.

Cheers for this! exactly what I needed today!

@github-actions
Copy link

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Aug 24, 2023
@debdutdeb
Copy link

// not stale.

@github-actions github-actions bot added on-hold Issues or Pull Requests with this label will never be considered stale and removed triage Triage is needed stale 15 days without activity labels Aug 24, 2023
@markverg
Copy link

We're using Apple Silicon as well and rather not rely on a workaround but stay with the Bitnami implementation (as we're using RocketChat and RocketChat suggests to use the Bitnami MongoDB image).

Therefor I wonder; does anyone have an update or estimation on this issue? Apple Silicon is out for a rather long time and here to stay I think. Is this issue deemed fixable and on a road map, or would it be best for us to plan under the assumption it won't be fixed in any foreseeable future?

@github-actions github-actions bot added triage Triage is needed and removed on-hold Issues or Pull Requests with this label will never be considered stale labels Aug 31, 2023
@carrodher
Copy link
Member

At this moment there is not a bitnami/mongodb multiarch image available. Having said that, we have an internal task still on our backlog to revisit the unsupported apps. We'll update this thread once done the mentioned task

@github-actions
Copy link

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Sep 20, 2023
@debdutdeb
Copy link

// not stale

@carrodher carrodher added on-hold Issues or Pull Requests with this label will never be considered stale and removed stale 15 days without activity labels Sep 20, 2023
@github-actions github-actions bot removed the triage Triage is needed label Sep 20, 2023
hackerwins added a commit to yorkie-team/yorkie that referenced this issue Jan 25, 2024
This PR adds a Helm chart for MongoDB, supporting both standalone mode
and sharded cluster mode.
Shard rules, including shard keys, shard methods, and unique
constraints, are defined and managed in the values.yaml.

This chart depends on Bitnami's mongodb-sharded chart
(https://github.com/bitnami/charts/tree/main/bitnami/mongodb-sharded).

There are a few known issues with it:

A problem with livenessProbe and readinessProbe
  - Issues: bitnami/charts#21957
  - Solution: use custom livenessProbe and readinessProbe instead

Lack of ARM64 support in the Bitnami mongodb-sharded container
- Issues:
  - bitnami/charts#7305 (comment)
  - bitnami/containers#40947
- Solution: use the official Mongo 6.0 image instead and set up the cluster via a Job.

---------

Co-authored-by: Youngteac Hong <[email protected]>
@izakdvlpr
Copy link

Same problem 🥲

@borodiliz
Copy link

Working on an M1 after upgrading to Docker Desktop 4.27.1 (Docker Engine 25.0.2) and enabling the EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU environment variable.

Example: docker run -e EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 --rm -it docker.io/bitnami/mongodb:7.0

docker/for-mac#6620

@DarhkVoyd
Copy link

@borodiliz hey, I am new to this, could you tell me how can I enable the variable in a docker compose based project?

@borodiliz
Copy link

@borodiliz hey, I am new to this, could you tell me how can I enable the variable in a docker compose based project?

@DarhkVoyd Sure. Same as other environment variables. Here is a complete example:

version: "3.8"
services:
  mongo: 
    image: bitnami/mongodb:5.0
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=127.0.0.1
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_ROOT_USER=elon
      - MONGODB_ROOT_PASSWORD=supersecret
      - MONGODB_REPLICA_SET_KEY=foobar123
      - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 # This is required on Apple Silicon https://github.com/docker/for-mac/issues/6620
    ports:
      - "27017:27017"
    volumes:
      - "mongo-db:/bitnami/mongodb"
volumes:
  mongo-db:

@DarhkVoyd
Copy link

@borodiliz

Finally!! It worked, thank you so much you are life saver. I wasted my entire week on this error.
Should I also explicity set platform: linux/amd64.

@neha-viswanathan
Copy link

neha-viswanathan commented Feb 28, 2024

Thanks @borodiliz!

EDIT: Please use this for local development ONLY!!!

For those using Helm, you can include this in the values file:

extraEnvVars:
  - name: EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU
    value: 1

@farcop
Copy link

farcop commented Apr 3, 2024

Guys, quemu emulation workaround is not suitable for Kubernetes use and not suitable for Production environments at all.
Its only workaround for some dev envs, not a solution yet.

@arnoldpistorius
Copy link

The workaround for local development works 🎉 . However I had to turnoff rosetta acceleration in Docker Desktop settings (Apple virtualization and virtIO can be enabled).

@carrodher carrodher closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
@carrodher carrodher reopened this Jul 1, 2024
@github-actions github-actions bot added triage Triage is needed and removed on-hold Issues or Pull Requests with this label will never be considered stale labels Jul 1, 2024
@carrodher carrodher added on-hold Issues or Pull Requests with this label will never be considered stale and removed triage Triage is needed labels Jul 16, 2024
@RezaOwliaei
Copy link

RezaOwliaei commented Sep 14, 2024

In my docker compose, it worked when I explicitly set platform: linux/amd64:

services:
  
  mongo:
    platform: linux/amd64
    image: bitnami/mongodb:7.0.14
    environment:
      - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1

@hemanth895
Copy link

hemanth895 commented Oct 5, 2024

Ran into same issue on Mac intel i7
i am getting exited with exit code 2

hemanth@Hitesh ordering-app % docker compose up
[+] Running 3/0
 ✔ Container ordering-app-mongodb-primary-1    Created                                                            0.0s 
 ✔ Container ordering-app-mongodb-secondary-1  Created                                                            0.0s 
 ✔ Container ordering-app-mongodb-arbiter-1    Created                                                            0.0s 
Attaching to mongodb-arbiter-1, mongodb-primary-1, mongodb-secondary-1
mongodb-primary-1    | mongodb 12:54:45.60 INFO  ==> 
mongodb-primary-1    | mongodb 12:54:45.61 INFO  ==> Welcome to the Bitnami mongodb container
mongodb-primary-1    | mongodb 12:54:45.61 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb-primary-1    | mongodb 12:54:45.62 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb-primary-1    | mongodb 12:54:45.63 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
mongodb-primary-1    | mongodb 12:54:45.64 INFO  ==> 
mongodb-primary-1    | mongodb 12:54:45.67 INFO  ==> ** Starting MongoDB setup **
mongodb-primary-1    | mongodb 12:54:45.74 INFO  ==> Validating settings in MONGODB_* env vars...
mongodb-primary-1    | mongodb 12:54:45.85 INFO  ==> Initializing MongoDB...
mongodb-primary-1    | mongodb 12:54:45.99 INFO  ==> Writing keyfile for replica set authentication...
mongodb-primary-1    | mongodb 12:54:46.02 INFO  ==> Deploying MongoDB from scratch...
mongodb-arbiter-1    | mongodb 12:54:46.12 INFO  ==> 
mongodb-arbiter-1    | mongodb 12:54:46.13 INFO  ==> Welcome to the Bitnami mongodb container
mongodb-arbiter-1    | mongodb 12:54:46.14 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb-arbiter-1    | mongodb 12:54:46.14 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb-secondary-1  | mongodb 12:54:46.14 INFO  ==> 
mongodb-secondary-1  | mongodb 12:54:46.22 INFO  ==> Welcome to the Bitnami mongodb container
mongodb-arbiter-1    | mongodb 12:54:46.21 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
mongodb-arbiter-1    | mongodb 12:54:46.22 INFO  ==> 
mongodb-arbiter-1    | mongodb 12:54:46.25 INFO  ==> ** Starting MongoDB setup **
mongodb-secondary-1  | mongodb 12:54:46.27 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb-secondary-1  | mongodb 12:54:46.28 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb-secondary-1  | mongodb 12:54:46.29 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
mongodb-secondary-1  | mongodb 12:54:46.30 INFO  ==> 
mongodb-secondary-1  | mongodb 12:54:46.32 INFO  ==> ** Starting MongoDB setup **
mongodb-arbiter-1    | mongodb 12:54:46.37 INFO  ==> Validating settings in MONGODB_* env vars...
mongodb-secondary-1  | mongodb 12:54:46.48 INFO  ==> Validating settings in MONGODB_* env vars...
mongodb-primary-1 exited with code 2
mongodb-arbiter-1    | mongodb 12:54:46.56 INFO  ==> Initializing MongoDB...
mongodb-secondary-1  | mongodb 12:54:46.66 INFO  ==> Initializing MongoDB...
mongodb-arbiter-1    | mongodb 12:54:46.72 INFO  ==> Writing keyfile for replica set authentication...
mongodb-arbiter-1    | mongodb 12:54:46.75 INFO  ==> Deploying MongoDB from scratch...
mongodb-secondary-1  | mongodb 12:54:46.77 INFO  ==> Writing keyfile for replica set authentication...
mongodb-secondary-1  | mongodb 12:54:46.81 INFO  ==> Deploying MongoDB from scratch...
mongodb-arbiter-1 exited with code 2
mongodb-secondary-1 exited with code 2

@josephdpurcell
Copy link

I was able to get bitnami/mongodb:7.0 to work on m1 with the combined advice from this ticket:

  1. Upgrade to at least Docker 25.0.2 (link to source)
  2. Set the platform in your docker-compose.yml to linux/amd64 (link to source)
  3. Set EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU to 1 as an env var in your docker-compose.yml (link to source)
  4. Disable rosetta (link to source)

Thank you @borodiliz, @RezaOwliaei, @arnoldpistorius, and everyone for posting.

In case it's useful there is also this related Stackoverflow thread where I added some more commentary: https://stackoverflow.com/a/79118553/990642

@padulkemid
Copy link

what if for users that don't use docker desktop (like orbstack) and such? the EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU is not working

@dlavrenuek
Copy link

I case you can use non-official images, I have created a custom built mongodb 6.x and 8.x arm64 versions compatible with bitnami/mongodb and bitnami helm charts. You can find the source code here: https://github.com/dlavrenuek/bitnami-mongodb-arm and the images are available on docker hub: https://hub.docker.com/r/dlavrenuek/bitnami-mongodb-arm. Please not that these images are only intended to be used for local development and not production usage.

Example usage:

global:
  security:
    # required to be set when using non-official images
    allowInsecureImages: true
image:
  registry: docker.io
  repository: dlavrenuek/bitnami-mongodb-arm
  tag: "8.0.4"

@mrayone
Copy link

mrayone commented Feb 16, 2025

Hi, I've used a macbook with M3 processor.
In my docker-compose I've follow the same example of @RezaOwliaei .

When I've put in EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU: 1, it works.

services:
  mongo:
    platform: linux/amd64
    image: 'bitnami/mongodb:8.0.4'
    ports:
      - "27017:27017"
    env_file:
      - .env
    healthcheck:
      test: ["CMD","mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 3s
      timeout: 5s
      retries: 5
    environment:
      MONGODB_USERNAME: ${DB_USER}
      MONGODB_PASSWORD: ${DB_PASSWORD}
      MONGODB_ROOT_PASSWORD: ${DB_PASSWORD}
      MONGODB_DATABASE: "test"
      EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU: 1
    networks:
      - "app"

networks:
  app:
    driver: bridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mongodb on-hold Issues or Pull Requests with this label will never be considered stale tech-issues The user has a technical issue about an application
Projects
None yet
Development

No branches or pull requests