How to pass a parameter from docker-compose to service runned in docker image?

独自空忆成欢 提交于 2019-12-11 07:24:53

问题


My docker-compose.yml, among other images, uses official mongo docker image:

mongodb:
    container_name: mongodb
    image: mongo:3.2
    volumes:
        - mongo_data:/data/db
    ports:
        - "57017:27017"
    restart: always

The problem is that I need mongo deamon to run with --httpinterface option. How can I change my docker-compose.yml to pass this parameter to the final CMD ["mongod"]?

Is it possible without touching the mongo image? Forking this image to only add one parameter would be an overkill.


回答1:


You can use command option of docker-compose.yml

mongodb:
    container_name: mongodb
    image: mongo:3.2
    command: mongod --httpinterface
    volumes:
        - mongo_data:/data/db
    ports:
        - "57017:27017"
    restart: always


来源:https://stackoverflow.com/questions/46401794/how-to-pass-a-parameter-from-docker-compose-to-service-runned-in-docker-image

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