How to Create mongodb & web-based interface container on Docker – Guide

MongoDB doesn’t need an introduction, whoever is administering and developing the system should already know that. It is a NoSQL database available for installation on popular operating systems to provide a database without a fixed structure and therefore easily scalable. Here in this article, we’ll learn the steps to easily install or create a MongoDB database server container on the Docker Engine platform.

what do we need to do in this tutorial?

Steps to Install MongoDB and Mongo Express on Docker

Make sure you have the Docker

The first thing I’m guessing is that you already have Docker installed on your system.

Download or extract the MongoDB Docker Image

The best thing that made Docker popular is its repository which contains hundreds of prebuilt images from official and unofficial sources. We can use them to create containers instantly, yes of course MongoDB is there too. Therefore, only on your machine run the Docker Pull command: docker pull mongo The above command will pull the latest version image on MongoDB Server into your Docker, however for any other version you must use the tag. For example, docker pull mongo: 4.4.9. For all available tags, you can see your page on Github. To check the downloaded image on the system, you can use: docker images

Create MongoDB Database Server Container

We already have the image, now use it to create as many database containers as you want. Before that, however, let’s create a folder on our system to store data from the databases created in the running MongoDB container. As we know, once we start using the database server for business use, your data becomes valuable, but in case we need to delete the container in the future, this process will also remove all your data. So to play it safe, let’s create a folder- sudo mkdir / var / dbdata

Now, create the Mongo Container:

docker run -it -d -v / var / dbdata: / data / db -p 27017: 27017 –name mongodb mongo Explanation of the above command: /var/dbdata:/data/db – Assigning our created folder to use to store MongoDB data. -p 27017: 27017: Opening database server container port to access from host system. –Name MongoDB: Assigning some name to our container mongo: It’s the name of the downloaded image file Start container: docker start mongodb

Access the MongoDB Database’s Terminal Docker (Bash Shell)

Now, if you want to access the Mongo server command line to create databases and manage them, here is the command: sudo docker exec -it mongodb bash Access the mongodb docker container command line

Create Mongo Express Web Interface container (optional)

Well, those who want a web-based graphical user interface to manage their Docker MongoDB server databases can go to the later Mongo Express installation by creating a container. docker run –link mongo_db_name_container: mongo -p 8081: 8081 -e ME_CONFIG_MONGODB_URL = ”mongodb: // mongo: 27017 ″ mongo-express Link your Docker by running the MongoDB server to Express, replacing the “mongo_db_name_container” above in the above command. For example, here we have created a database container named mongodb, so the above command will be: docker run –mongodb link: mongo -p 8081: 8081 -e ME_CONFIG_MONGODB_URL = ”mongodb: // mongo: 27017 ″ mongo-express To access the web interface, open your browser and type: http: // localhost: 8081

Final note

I hope you like the guide How to Create mongodb & web-based interface container on Docker. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.

How to Create mongodb   web based interface container on Docker  2022  - 75How to Create mongodb   web based interface container on Docker  2022  - 43How to Create mongodb   web based interface container on Docker  2022  - 26How to Create mongodb   web based interface container on Docker  2022  - 3