Skip to content

Instantly share code, notes, and snippets.

@milianoo
Last active June 19, 2017 08:36
Show Gist options
  • Save milianoo/537211c4f9cb7d8d4665ee4c3e2d848f to your computer and use it in GitHub Desktop.
Save milianoo/537211c4f9cb7d8d4665ee4c3e2d848f to your computer and use it in GitHub Desktop.
Run mongodb instance using docker containers in your local system
1. Install Docker.
please follow docker tutorial for installation on your system
https://docs.docker.com/engine/installation/
2. Now there are two options to run Mongodb
2.1 Create your own Dockerfile
2.2 Use existing images available on Docker-Hub
3. Run existing image on docker hub :
`docker run -p 27017 --name mongodb_01 -d mongo`
4. access to your mongo shell on docker container :
`docker exec -it mongodb_01 mongo`
5. access to your mongo shell using your local mongo shell :
5.1 run `docker ps`
5.2 check the running port of the container `0.0.0.0:32768->27017/tcp`
5.3 use the port to connect to the container `mongo --port 32768`
6. sample connection string for connecting : `mongodb://0.0.0.0:32768/?maxPoolSize=9999`
7. restore your currnet database dump to the remote docker mongodb
`mongorestore --host 0.0.0.0:32768 -d Local-test ./dump/Local-test/`
I hope this is usefule for you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment