Discussions

Ask a Question
Back to All

Change mongodb default volume mapping

By default, the MongoDB image persists its database under a volume located at /data/db. Any idea how I can change this via Medstack control? This is easy enough to configure in a docker-compose file, as represented below. With the following configuration, the MongoDB database gets stored under /mongodb/data instead of /data/db. I'd like to match this behavior in my MedStack cluster.

mongo:
    container_name: mongo-server
    image: mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: ****
      MONGO_INITDB_ROOT_PASSWORD: ****
    volumes:
      - /mongodb/data:/data/db
    ports:
      - 27017:27017

References:

https://www.mongodb.com/compatibility/docker

https://hub.docker.com/_/mongo