how to add --auth for mongodb image when using docker-compose? how to add --auth for mongodb image when using docker-compose? nginx nginx

how to add --auth for mongodb image when using docker-compose?


Supply a command to the container including the --auth option.

  mongodb:    image: mongo:latest    expose:        - "27017"    volumes:        - "/home/open/mymongo:/data/db"    command: mongod --auth

The latest mongo containers come with "root" auth initialisation via environment variables too, modelled on the postgres setup.