简体   繁体   English

我可以将参数传递给docker-compose命令配置选项吗

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

Anyone know how I can use the command: option in docker-compose to run my command with arguments? 有谁知道我如何使用docker-compose中的command:选项运行带有参数的命令? 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. 我知道版本2提供了参数,但是可以与docker-engine 1.10.x一起使用,我在docker-engine 1.6.2上,目前无法升级。

I want to do something like this in docker-compose: 我想在docker-compose中做这样的事情:

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

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 . 请(重新)阅读docker-compose 文档 ,docker-compose.yml command指的是在容器内执行的实际命令,而不是您传递给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 . 要在容器启动后分离,请使用docker-compose up -d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM