Skip to content

Instantly share code, notes, and snippets.

@httpJunkie
Last active April 4, 2020 09:05
Show Gist options
  • Save httpJunkie/cd20a8d36ce89f3b6d1cf7a0c0bb8212 to your computer and use it in GitHub Desktop.
Save httpJunkie/cd20a8d36ce89f3b6d1cf7a0c0bb8212 to your computer and use it in GitHub Desktop.
Run Mongo with Docker

Run Mongo using Docker

This guide will get you up and running with Mongo

Download latest Image

docker pull mongo:X.X.X

Installing and Running Mongo in Detached Mode (In Background and able to connect from server)

docker run -d -p 27017-27019:27017-27019 --name mongoXXX mongo:X.X.X

latest version as of this writing is 4.2.5 which we would name mongo425 like so:

docker run -d -p 27017-27019:27017-27019 --name mongo425 mongo:4.2.5

Connecting to Mongo Shell

docker exec -it mongo425 bash

then run:

> mongo

> show dbs

> use task-management

This will first show us the current databases and then we create a new database called task-management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment