I've been trying to start a mongoDB and cassandra container and make them pass two simple health checks, but they keep failing no matter what health check I put:
For mongoDB, here's my yml file:
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
and for cassandra:
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
Am I missing something,
I also tried running this for the health check:
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