If your application is running inside a container itself, you can run MongoDB as part of the same Docker network as your application using --network. With this method, you will connect to MongoDB on mongodb://mongodb:27017 from the other containerized applications in the network.
Note: When using the terminal method, ensure to replace the MongoDB Compass file name with the existent file name of the downloaded file. If unsure, cd to the Downloads section and use the ls command to check and copy the file name. This will help you evade unnecessary errors.
Once the installer file has been downloaded and saved to your PC, locate the downloaded file and unzip it using any of your favorite applications. For illustration purposes, I will be using the WinRAR application.
For this to work, you need to have a copy of the SSL Certificate for the Compose deployment. If you look back at the Connection Info panel, just below it is the SSL Certificate (Self-Signed) panel. Click the Show Certificate button, authenticate and the panel will display certificate. Select the certificate's text, copy it and paste it into a local file using your preferred text editor. We'll save our example as compassexample.pem.
In this tutorial, You will learn to download and install MongoDB Compass and connect to localhost. If you are working with the MongoDB database then you should use the compass software to view & modify your table data quickly within a few seconds.
Remember the connection string we talked about earlier? Good. We're going to use that on VS Code to connect to our newly created database.The connection string for our database will be: mongodb://localhost:27017/myDatabase, paste this in the text bar at the top of the window, that is, step 3 in the diagram below:
MongoDB compass can be easily downloaded from the MongoDB downloads site. Once you have downloaded and installed MongoDB Compass, start the application, and you would be welcomed by a screen similar to the screen shown below. 2b1af7f3a8