The mongodb docker container takes few seconds to receive connections on the specified port. I would like to know how we can check if that port is up before continuing.
Asked
Active
Viewed 2,330 times
1
-
Use Dockerfile HEALTHCHECK. https://stackoverflow.com/a/38300925/193016 – kroiz Oct 14 '18 at 19:12
1 Answers
2
If mongodb is configured to accepted connection on localhost:27017
then run the following command:
TIMEOUT=30; until $(curl --output /dev/null --silent --fail localhost:27017); do printf '.'; sleep 1; if [[ $var -eq ${TIMEOUT} ]] ; then exit 1; fi; var=$((var+1)); done

Bilal Baqar
- 208
- 2
- 12