Connect to service outside of your docker container

I was trying out as an alternative to Heroku (it's fantastic, btw). Convox requires apps to be in docker containers and have a handy convox start which boots up the app using docker compose. This worked great except that I don't have mongo dockerized and my ruby app couldn't connect to the mongo instance I had running on localhost. After too many hours, a quick question in the public convox slack room fixed things.

If you have an app running inside docker contianer and you want to connect to Mongo (or Postgres or anything else) that's running on localhost, use the ip address.

It's that simple!

Scott Messinger

Read more posts by this author.