Step 1: Install Docker on your local machine

See the fantastic set of instructions here.

Step 2: Set up a MongoDB Docker container

Pull down the pre-built mongo image from the Docker repository:

docker pull mongo

Start a Docker container:

docker run
-d
--name YOUR_CONTAINER_NAME_HERE
-p YOUR_LOCALHOST_PORT_HERE:27017
-e MONGO_INITDB_ROOT_USERNAME=YOUR_USERNAME_HERE
-e MONGO_INITDB_ROOT_PASSWORD=YOUR_PASSWORD_HERE
mongo

Check that the container’s up and running:

docker container ls

(you should see your container listed)

Step 3: Connect to the container and access your MongoDB instance

Start + connect to a bash shell within the container:

docker exec -it YOUR_CONTAINER_NAME_HERE bash

Access the MongoDB instance via the…

Tom Szpytman

Full-stack + Product. Available for hire either as an independent contractor, or as part of a voliyo.dev team. Inquiries: mail [at] voliyo.dev.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store