Mongo Installation

To install MongoDB using Docker, you can follow these steps:

  1. Pull the MongoDB Docker Image

    First, pull the official MongoDB image from Docker Hub:

    docker pull mongo
  2. Start and Persist Data

    To ensure data persists across container restarts, you can mount a volume:

    docker run --name mongodb -d -p 27017:27017 -v /my/own/datadir:/data/db mongo

    Replace /my/own/datadir with the path to the directory on your host machine where you want to store MongoDB data.

By following these steps, you can set up and run a MongoDB instance using Docker.

Last updated