Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

Managing the MongoDB Instance

shalewis edited this page Feb 5, 2015 · 14 revisions

Start Boot2Docker

Not required for Linux. In Windows and OSX, you must start up the lightweight Linux virtual machine. In Windows, open MSYS-git, also known as Git Bash. In OSX, open a terminal.

Type in the following:

  • boot2docker init - it will create a lightweight linux virtual machine in VirtualBox. If it's already created, it will throw an error (which you can ignore)
  • boot2docker up - this will start the virtual machine

In windows, follow this up with the following command

  • boot2docker ssh - this will allow you to ssh into the virtual machine so that you can execute docker commands. Please note that as soon as you ssh into boot2docker, you will not be able to run additional boot2docker commands. You will need to open another shell to do that.

Starting the Linux Container with MongoDB

To start the linux container for the MongoDB instance, run the following command docker run -d -p 27017:27017 --name snp-mongodb jlgrock/snp-prototype-mongodb (In Windows, this should be run in the boot2docker VM - using boot2docker ssh. In Linux, you need to run this command using sudo).

Starting the Linux Container with MongoDB Client (and test scripts)

To start the linux container for the MongoDB instance, run the following command docker run -it --name snp-mongodb-client --link snp-mongodb:mongo --rm jlgrock/snp-prototype-mongodb-client (In Windows, this should be run in the boot2docker VM - using boot2docker ssh. In Linux, you need to run this command using sudo). This will start up a client container that will be running Mongo Shell and allow you to interact with it. You will need to open a new terminal window if you still need to access boot2docker or your local linux instance.

Finding the IP address (on non-Linux machines)

In Windows and OSX, since you are running within a Virtual Machine, you have to find the ip address using the command boot2docker ip. This will be necessary for connecting to this instance.

Connecting to the MongoDB Instance

Click through to the article on Connecting to the MongoDB Instance

Stopping the Linux Container

To stop the Linux container, just run the following command docker kill snp-mongodb (In Windows, this should be executed within the boot2docker Virtual Machine. In Linux, you need to run this command using sudo). To cleanup, you should likely follow this with a docker rm snp-mongodb as well, so that you have no issues starting another container with the same name going forward.

Clone this wiki locally