Hey, guys. This time, we will show you how to install MongoDB using Docker Compose.
I have to admit that these last days I have liked much more the technology of Docker compose. It seems a very simple and fast way to install certain applications. However, from my point of view, a bit of flexibility is lost in the configurations since they are images already created from a base. Of course, we will be able to configure some things but not everything.
In Osradar we have written several times about MongoDB. Not in vain is one of the NoSQL database management systems based on the most popular documents out there. Widely used in mobile applications as well as in transactional systems, MongoDB stands out for its flexibility and query speed.
Fast, robust and high performance are some of the main features of MongoDB.
So, let us start.
Install Docker and Docker Compose on Linux
The first step is to have Docker installed in the system, obviously.
In this file, two services are specified. Firstly, the one we are interested in is MongoDB. The definition is quite simple because you only have to configure as environment variables, the initial database, as well as the password and the root user.
The interesting thing is that I add a local folder /home/angelo/mongodata as volume so that it communicates with the container and thus to store the data. In other words, the database and collections will be stored in that folder. Obviously, specify the one you want but you must create it before making this file.
The second service is mongo-express which is a graphical interface built with NodeJS and express to manage MongoDB. There the important thing is that the execution port is 8081. You can change it, obviously.
Then, we can “raise” the images. To do this, just use this command:
:~$ sudo docker-compose up -d
After that, open your web browser and go to http://your-server:8081
Next, you can for example, create a new database.
And create a new collection.
So, everything is perfect.
MongoDB is a powerful database manager. Today we have learned to install it using Docker Compose. So how to use it a lot. Remember that installing it this way is recommended for servers and production systems and not so much for development.
Osradar is a non-profit website managed by the Old Unixmen owner Mel khamlichi, we offer fresh news about Tutorials Security and Opensource . Please Stay connected and Enjoy with us this wonderful website