1

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.

Bilal Baqar
  • 208
  • 2
  • 12

1 Answers1

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