Deploy MongoDB as a Docker container


In this tutorial, How to Deploy MongoDB as a Docker container. MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.

You need to install Docker on Ubuntu.

How to Deploy MongoDB as a Docker container

First, We will pull version MongoDB as command below:

docker pull mongo:3.4.4
docker MongoDB

To create a volume for the database and retain data. The command line creates the volume as below:

docker volume create mongo_data

We will deploy it

docker run -d -v mongo_data:/data/db --name mymongoDB --net=host mongo:3.4.4 --bind_ip --port 27000

You need to verify the deployment as command below:

docker ps -a
deploy mongoDB

The container is running, How to access it?

docker exec -it mymongoDB mongo localhost:27000
Access mongoDB container

If you need to stop the MongoDB container.

docker stop ID

If you need to start the MongoDB container.

docker start ID
docker stop mongoDB


You deploy MongoDB as a Docker container. I hope this will be helpful. Thank you for reading the DevopsRoles page!

, ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.