note: This question was asked also on stack overflow - http://stackoverflow.com/questions/34467171/circleci-best-way-to-verify-if-docker-containers-are-responding-via-http
here is an example of part of my circle.yml how I am currently verifying if my mongodb docker container is responding to an http request, so that I can verify if the response is ok and that the server is up.
test: override: # RUN DOCKER CONTAINERS # MongoDB ------------- - docker run --name MongoDB -p 27018:27018 -d mongo:3.0 mongod --port 27018 --replSet "rs"; sleep 10 - curl --retry 10 --retry-delay 5 -v http://localhost:27018
curl it’s working fine, sometimes.
And sometimes it gives me this error:
* About to connect() to localhost port 27018 (#0) * Trying 127.0.0.1... Connection refused * couldn't connect to host * Closing connection #0
How can I improve this, to make it more reliable so my tests won’t sometimes pass and sometimes fail, if I rebuild the same build?