【问题标题】:Docker health check always fails for mongodb and cassandramongodb 和 cassandra 的 Docker 健康检查总是失败
【发布时间】:2021-09-07 09:04:06
【问题描述】:

我一直在尝试启动一个 mongoDB 和 cassandra 容器,并让它们通过两个简单的健康检查,但无论我进行什么健康检查,它们都会失败:

对于 mongoDB,这是我的 yml 文件:

version: '3.1'

services:

  mongo:
    image: mongo:3.6.3
    restart: always
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
    healthcheck:
      test: ["CMD", "mongo --quiet 127.0.0.1/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)'"]
      start_period: 5s
      interval: 5s
      timeout: 120s
      retries: 24

对于卡桑德拉:

version: '2'

services:
  cassandra:
    image: 'docker.io/bitnami/cassandra:3-debian-10'
    ports:
      - '7000:7000'
      - '9042:9042'
    volumes:
      - 'cassandra_data:/bitnami'
    environment:
      - CASSANDRA_SEEDS=cassandra
      - CASSANDRA_PASSWORD_SEEDER=yes
      - CASSANDRA_PASSWORD
      - MAX_HEAP_SIZE=1G
      - HEAP_NEWSIZE=800M
    healthcheck:
      test: [ "CMD-SHELL", "cqlsh --username cassandra --password ${CASSANDRA_PASSWORD} -e 'describe cluster'" ]
      interval: 5s
      timeout: 120s
      retries: 24

我是不是错过了什么,

我也尝试运行它来进行健康检查:

echo 'db.runCommand({serverStatus:1}).ok' | mongo admin -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --quiet | g$$et | grep 1```
I went trough a lot of the discussions about the healthchecks for mongo and cassandra, but still not able to make it work

【问题讨论】:

    标签: mongodb docker docker-compose cassandra


    【解决方案1】:

    首先,你不应该使用 CMD-SHEEl 而是 CMD: Related github issue

    您能否分享健康检查状态和任何对您有用的日志?

    我认为这个帖子可以帮助你:Why does the docker-compose healthcheck of my mongo container always fail?

    此致,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-01
      • 1970-01-01
      • 2019-05-05
      • 1970-01-01
      • 2020-12-18
      • 1970-01-01
      • 2015-01-23
      • 2017-06-09
      相关资源
      最近更新 更多