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.
Install the MongoDB server and UI
mkdir mongodb-server
cd mongodb-server
wget https://goo.gl/4vTPgy -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
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.
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).
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://127.0.0.1:27017
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