When I ping the ip address from bash, I get a time-out. If I try to connect to using a mongo client like MongoChef using the ip address and the EXPOSED port, I get a timeout…
It seems so simple, yet something is eluding me. Is there anything that I may be missing?
You need to give a -p (or -P) option to cause Docker to publish a port. Something being EXPOSEd in a Dockerfile doesn’t cause anything to happen (except that -P will assign a port for it).
The examples on Docker show docker run --link to make the database accessible from other containers, which is different from accessing it from the host (or from other host).
If you ran, for instance,
docker run -d -p 27017:27017 mongo
then your host code could connect to localhost:27017 to access the database.
I’ve generally found using Docker’s native networking capabilities, like docker run -p to publish a specific port from the host, to work fine, and almost never need to know a container’s IP address. (The recent changes in Docker for Mac beta 9 make it work essentially the same way as Docker for native Linux.)