I'm using docker-compose to run my project created by node,mongodb,nginx;
and I have build the project using docker build
and then I use docker up -d nginx
to start my project. but I haven't found the config to run mongodb image with '--auth', so how to add '--auth' when compose start the mongodb?
here is my docker-compose.yml:
version: "2"
services:
mongodb:
image: mongo:latest
expose:
- "27017"
volumes:
- "/home/open/mymongo:/data/db"
nginx:
build: /home/open/mynginx/
ports:
- "8080:8080"
- "80:80"
links:
- node_server:node
node_server:
build: /home/laoqiren/workspace/isomorphic-redux-CNode/
links:
- mongodb:mongo
expose:
- "3000"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With