healthcheck
healthcheck copied to clipboard
Update docker-healthcheck for mongodb 6.0+
Due an upgrade of mongodb version 6.0.0+ The mongo
command was changed to mongosh
command.
I notice the mongosh
was introduced in 4.2 version: https://www.mongodb.com/docs/mongodb-shell/install/#std-label-mdb-shell-install
- "You can use the MongoDB Shell to connect to MongoDB version 4.2 or greater."
However, I notice version 4.4 was not working and the mongosh was included just in 5.0+, so, I decided to build 3 images:
- 4.4 version
- 5.0 version
- latest version
With these images I can test using the following command:
git clone https://github.com/edualb/healthcheck.git
cd ./healthcheck
git switch patch-1
cd ./mongo
docker build -f ./Dockerfile.4.4 -t mongo-healthy:4.4 . \
&& docker build -f ./Dockerfile.5.0 -t mongo-healthy:5.0 . \
&& docker build -f ./Dockerfile.latest -t mongo-healthy:latest .
docker run -d mongo-healthy:4.4 \
&& docker run -d mongo-healthy:5.0 \
&& docker run -d mongo-healthy:latest
# You can follow the healthy of each container by running docker ps
docker ps
# After checking if it is working or not you can remove all containers:
docker rm -rf $(docker ps -q)
output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d2b77d5bcc46 mongo-healthy:latest "docker-entrypoint.s…" 6 minutes ago Up 6 minutes (healthy) 27017/tcp funny_shaw
8032e78b6f79 mongo-healthy:5.0 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes (healthy) 27017/tcp admiring_beaver
52a25acfe7e6 mongo-healthy:4.4 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes (healthy) 27017/tcp boring_gould