Can I pass arguments into docker-compose the command config option

天涯浪子 提交于 2019-12-11 12:21:58

问题


Anyone know how I can use the command: option in docker-compose to run my command with arguments? I know version 2 offers arguments, but that works with docker-engine 1.10.x I am on docker-engine 1.6.2 and cannot upgrade at the moment.

I want to do something like this in docker-compose:

...
rstudio:
  image: rocker-hadleyverse
  command: -d -p 8787:8787 -e USER=<username> -e PASSWORD=<password> rocker-hadleyverse
  links:
    - db
...

回答1:


Please (re)read the docker-compose docs, in docker-compose.yml command refers to the actual command executed inside the container, not the options you pass to docker run. Your example translates to:

rstudio:
  image: rocker-hadleyverse
  ports:
    - "8787:8787"
  environment:
    - USER=foo
    - PASSWORD=bar
  links:
    - db

To detach after container start use docker-compose up -d.



来源:https://stackoverflow.com/questions/35796353/can-i-pass-arguments-into-docker-compose-the-command-config-option

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