The last part of our MEAN set up, before we connect them all together is the MongoDB. Now, we can't have a Dockerfile to build a MongoDB image, because one already exists from theDocker Hub. We only need to know how to run it.
Assuming we had a MongoDB image already, we'd run a container based on the image with
$ docker run -d --name mongodb -p 27017:27017 mongo
The image name in this instance ismongo, the last parameter, and the container name will bemongodb.
Docker will check to see if you have a mongo image already downloaded, or built. If not, it will look for the image in the Dockerhub. If you run the above command, you should have mongodb instance running inside a container.
To check if mongodb is running, simply go tohttp://localhost:27017in you browser, and you should see this message.It looks like you are trying to access MongoDB over HTTP on the native driver port.
Alternatively, if you have mongo installed in your host machine, simply runmongoin the terminal. And it should run and give you the mongo shell, without any errors.