Setting up MongoDB environment using Docker

TheDevStory
2 min readNov 2, 2022

--

Downloading the DB to a local location is easy. However, sometimes problems may occur depending on the operating system and environment. In this situation, we can use Docker. Using DB with Docker can prevent this kind of conflict. From now on, I will show you how to use Mongo DB with Docker on the assumption that you have installed Docker.

requirements

(just) docker

Pull image

Docker Image is all the files and settings for running a specific process. In other words, the form of bundled server programs, source codes and libraries, and compiled executable files required for service operation is called Docker Image. In short, if you have an image, you can use it well without worrying about dependencies.

Let’s pull the MongoDB image.

docker pull mongo

Run

The run command is a bit complicated.

docker run --name practice-mingo -p 37017:27017 -d mongo
  • --name [project-name] : make your docker container name for the identifier
  • -p 37017:27017 : Adjust the port to assign 31017 -> 27017

checking it’s running

docker ps

If you see a new container called mongo, you can use MongoDB.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

TheDevStory
TheDevStory

Written by TheDevStory

A web developer crafting online experiences. Also football(soccer) coach and Spanish Learner.

No responses yet

Write a response