Installing MongoDB through Docker

Jose Salvatierra
School of Code
Published in
1 min readFeb 9, 2016

Installing MongoDB can sometimes be a bit of a pain, especially with all the versions that are available and whatnot. Recently one of my students recommended that I suggest installing MongoDB through Docker.

I thought this wouldn’t be realistically feasible for someone who is just starting, but actually it’s really simple! I’ll give you a list of steps:

  1. If you are in Windows or Mac OS X, install Docker Toolbox.
  2. Now, run the Docker Quickstart Terminal application. This will initialise the Docker environment.
  3. After, you can close that window and run the Kitematic application that should’ve been installed alongside it.
  4. Now, search for the mongo container.
  5. Create this container, and when it’s finished, MongoDB is installed!

Now, logging into the container is very easy: simply press the Exec button at the top of the Kitematic window. Then, you can initiate a mongo shell solely by typing:

mongo

To use MongoDB from your applications just use the address and port provided (they appear on the right-hand side of the Kitematic window). It will be something like the following:

192.168.<n>.<n>:<port>

To connect to the Docker mongod process from your own Terminal, you’ll have to do the following (using the details from the Kinematic window):

mongo --host=192.168.<n>.<n> --port=<port>

If you’ve got any problems, just comment below!

--

--