You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker Compose中配置MongoDB eviction参数失败,求正确配置方法

MongoDB Docker Compose中eviction参数配置失败的解决方法

你遇到的问题是YAML解析command参数时的引号处理错误导致的——wiredTigerEngineRuntimeConfig的值包含括号、逗号这类特殊字符,直接用双引号包裹会让YAML或shell错误拆分参数,进而导致MongoDB服务启动失败。

推荐用数组形式定义command,这种方式能明确拆分每个参数,彻底避免解析歧义,修改后的配置如下:

mongodb-geo:
    image: mongo:5.0
    hostname: geo-db
    volumes:
      - geo:/data/db
    command:
      - --wiredTigerCacheSizeGB
      - "1"
      - --setParameter
      - wiredTigerEngineRuntimeConfig=eviction=(threads_min=6,threads_max=12)
    restart: always
    deploy:
      replicas: 1
      resources:
        limits:
          cpus: '0.3'
      restart_policy:
        condition: any

验证参数是否生效

容器启动后,进入容器执行以下命令确认配置:

mongosh --eval 'db.runCommand({getParameter: "*", wiredTigerEngineRuntimeConfig: 1})'

返回结果中若能看到wiredTigerEngineRuntimeConfig对应值为eviction=(threads_min=6,threads_max=12),则说明配置成功。

内容的提问来源于stack exchange,提问作者OmG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 01:14:56