Setting up MongoDB
There are several ways to install MongoDB, but we will use Docker Compose to install it locally. Docker Compose is a tool for defining and running multi-container Docker applications. With Docker Compose, we will be able to run MongoDB and our web application in different containers. If you are not familiar with Docker, there is a fantastic guide from MongoDB (https://www.mongodb.com/compatibility/docker) that can help you get a deeper understanding.
Installing Docker
If you don’t have Docker installed, you can follow the instructions at https://docs.docker.com/get-docker/, depending on your operating system.
Checking the installation
Let’s check that Docker is installed correctly. Open a terminal and run the following command:
docker --version
You should see the version installed – in my case, 24.0.2:
Docker version 24.0.2, build cb74dfc
We can also check that Docker Compose is installed correctly. Open a terminal and run...