MongoDB 5.0+ requires a CPU with AVX support. Container failed to start
Asked Answered
F

4

7

I am trying to run mongo:6 in docker container with docker compose file but it always gets exited with warning.

Docker version : 23.0.4, build f480fb1

Docker-compose version: v2.17.2

docker-compose.yml

version: '3.8'
services:  
  mongo-db:
    container_name: mongo-db
    image: mongo:6
    volumes:
      - ../psvolumes/mongo6:/data/db
    environment:
      - COMPOSE_PROJECT_NAME=mongo
      - MONGO_INITDB_ROOT_USERNAME=
      - MONGO_INITDB_ROOT_PASSWORD=
    ports:
      - 27017:27017
    networks:
      - mongo_network
    restart: unless-stopped
networks:
    mongo_network:
        driver: bridge

docker compose up

Output:

[+] Running 2/1
 ✔ Network ams-api_mongo_network  Created                                                                                                                                        0.1s 
 ✔ Container mongo-db             Created                                                                                                                                        0.0s 
Attaching to mongo-db
mongo-db  | 
mongo-db  | WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that!
mongo-db  |   see https://jira.mongodb.org/browse/SERVER-54407
mongo-db  |   see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2
mongo-db  |   see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814
mongo-db  | 
mongo-db exited with code 0

But it is always restarting and not get started

Click here for docker logs

Fossilize answered 28/4, 2023 at 5:1 Comment(5)
The latest one without AVX is 4.4.6. Ref: github.com/docker-library/mongo/issues/485Susquehanna
What platform (arch, CPU, etc) are you running docker on?Plowshare
I am running on centos 9. Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 40 bits physical, 48 bits virtual Byte Order: Little Endian Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz CPU family: 6 Model: 44 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 4 Stepping: 2 BogoMIPS: 5320.00Fossilize
I recently ran into this issue inside a VM running Alma Linux on Windows. Turns out having the virtualization Windows feature enabled breaks AVX support. Also, Core Isolation (memory integrity) uses Hyper-V and breaks much more.Inutile
If your hypervisor is proxmox, change CPU to host instead of kvm64 or etc. It'll resolve the issue same mine.Cynic
A
6

if you are using proxmox just change cpu type (Hardware > Edit Processors) to host and reboot vm.

enter image description here

Apoplexy answered 22/8, 2023 at 7:55 Comment(0)
I
2

There's a container solving this problem

nertworkweb/mongodb-no-avx

https://hub.docker.com/r/nertworkweb/mongodb-no-avx/tags

Inanna answered 3/8, 2023 at 15:20 Comment(0)
A
0

MondoDB needs the avx flag, but unfortunately it checks the reported-model and not the flags.
So if you want to keep your cpu-model as compatible as possible,
you have to add the avx flag and overwrite the reported-model:

Proxmox example:

cpu-model: mongodb_kvm64
    flags +avx
    phys-bits host
    hidden 0
    hv-vendor-id proxmox
    reported-model SandyBridge
Arvizu answered 13/10, 2023 at 7:37 Comment(0)
P
0

If you area nn MacOS Apple silicon processors (M1,M2...), you can solve passing the platform parameter in docker run:

docker run --platform linux/arm64/v8 ...

or in your docker-compose file:

services:
  mongodb:
    image: arm64v8/mongo:5.0
    platform: linux/arm64/v8

Regards

Plantagenet answered 10/10 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.