equivalent of docker option --config in docker-compose

孤者浪人 提交于 2019-12-25 00:42:13

问题


I'm trying to run mongo with docker-compose. From the docker mongo page I have the following command

$> docker run --name some-mongo -v /my/custom:/etc/mongo -d mongo --config /etc/mongo/mongod.conf

version: '3'
services:
  db:
    image: mongo:4
    ports: 
      - "27017:27017"
    volumes:
      - ./storage/mongo:/data/db:rw

Now I would also like to define the mongod.conf; --config /etc/mongo/mongod.conf but how can you do that inside docker-compose?


回答1:


The --config is part of mongo, not docker. You may still use it with docker-compose like

docker-compose run db --config /etc/mongo/mongod.conf



回答2:


You can use command

services:
  db:
    image: mongo:4
    command: "mongo --config /etc/mongo/mongod.conf" 
    ports: 
      - "27017:27017"
    volumes:
      - ./storage/mongo:/data/db:rw


来源:https://stackoverflow.com/questions/56097915/equivalent-of-docker-option-config-in-docker-compose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!