Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize the configuration file by docker-compose.yml? #359

Closed
mycrl opened this issue Jul 24, 2019 · 3 comments
Closed

How to customize the configuration file by docker-compose.yml? #359

mycrl opened this issue Jul 24, 2019 · 3 comments

Comments

@mycrl
Copy link

mycrl commented Jul 24, 2019

I want to start the mongodb service in docker-compose.yml and specify the database directory and log file output through a custom configuration file. How do I do this?

@mycrl
Copy link
Author

mycrl commented Jul 24, 2019

docker-compose.yml

version: "3"
services:
  mongod:
    image: mongo:4.1.13
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: test
      MONGO_INITDB_ROOT_PASSWORD: test
    deploy:
      replicas: 1
    volumes:
      - /root/data/mongod:/root/data
      - /root/logs/mongod:/root/logs
      - ./mongod.conf:/etc/mongod.conf
    ports:
      - 27017:27017
    command: --config /etc/mongod.conf

mongod.conf

systemLog:
  verbosity: 0
  destination: file
  path: /root/logs/mongod.log
  timeStampFormat: iso8601-utc
storage:
  directoryPerDB: true
  dbPath: /root/data
  engine: wiredTiger
  wiredTiger:
    engineConfig:
      cacheSizeGB: 1
  journal:
    enabled: true
processManagement:
  fork: true
net:
  port: 27017
  bindIp: 0.0.0.0
security:
  authorization: enabled

I can't start this service.

@mycrl mycrl closed this as completed Jul 24, 2019
@jingmian
Copy link

jingmian commented Aug 6, 2019

Have you found a way? I have this problem, too.

@jingmian
Copy link

jingmian commented Aug 31, 2019

version: "3"
services:
  mongod:
    image: mongo:4.1.13
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: test
      MONGO_INITDB_ROOT_PASSWORD: test
    deploy:
      replicas: 1
    volumes:
      - /root/data/mongod:/root/data
      - /root/logs/mongod:/root/logs
      - ./mongod.conf:/etc/mongod.conf
    entrypoint: ["mongod","--config","/etc/mongod.conf"]
    ports:
      - 27017:27017

add entrypoint: ["mongod","--config","/etc/mongod.conf"]

@docker-library docker-library locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants