It is very easy using docker-compose to setup a local MongoDB server and UI.

Install docker-compose

Install docker-engine, of cause, then install the docker-compose python scripts

# remember to install docker-engine first!
pip install docker-compose

Copy the docker-compose file to an empty folder

Copy the following docker-compose.yml file into an empty folder.

version: '2'

networks: mongodbnet: driver: bridge ipam: driver: default config: # Change this subnet range if it conflicts with your personal/work network - subnet: gateway: services: mongodb: image: mongo:latest containername: mongodb hostname: mongodb networks: - mongodbnet ports: - 27017:27017 mongoclient: image: mongoclient/mongoclient:latest containername: mongoclient hostname: mongoclient dependson: - mongodb networks: - mongodbnet ports: - 3300:3000

Install the MongoDB server and UI

mkdir mongodb-server
cd mongodb-server
wget -O docker-compose.yml
docker-compose up -d

The docker-compose file sets the following ports on the hypervisor

  • 27017(TCP): MongoDB server
  • 3300(TCP): MongoDB UI

At this point you can point your web browser to http://localhost:3300 to access the UI. By default MongoDB does not use any authentication.

Screenshots showing UI setup

Select the Connect Button to view the connection Screenshots

click connect button

Enter the MongoDB connection server info. Note: the MongoDB hostname is MongoDB. Remember the UI sits on a special network where it can reference the MongoDB server by name. So use this name, not localhost. The database name can be anything you want and does not need to be setup ahead of time. In this case, test is used. enter connection info

connect to the database

Finally the mongoclient UI should inform you that you have a successful connection and begin to show pretty graphs and an easy way to add database entries(documents).

final connection view

How to access the MongoDB CLI

Docker exec action allows you to access the mongo CLI

% docker exec -it MongoDB mongo               
MongoDB shell version v3.4.1
connecting to: MongoDB://
MongoDB server version: 3.4.1
Server has startup warnings:
2016-12-26T19:13:05.646+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2016-12-26T19:13:05.646+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2016-12-26T19:13:05.646+0000 I CONTROL  [initandlisten]
> show dbs
admin  0.000GB
local  0.000GB