Source

version: '3.9'

services:
    mongo:
      image: mongo:4.4.6
      healthcheck:
        test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
        interval: 10s
        timeout: 10s
        retries: 5
      user: 1000:1000
      volumes:
        - /mnt/docker/data/mongo/db:/data/db
        - /mnt/docker/data/mongo/configdb:/data/configdb
        - /mnt/docker/data/mongo/init:/docker-entrypoint-initdb.d/:ro
      ports:
        - 27017:27017
      environment:
        - PUID=1000
        - PGID=1000
        - TZ=Etc/UTC
        - MONGO_INITDB_ROOT_USERNAME=root
        - MONGO_INITDB_ROOT_PASSWORD=password