4

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
...
Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
Slenny
  • 379
  • 2
  • 4
  • 13
  • Possible duplicate of [How to pass arguments within docker-compose?](http://stackoverflow.com/questions/34322631/how-to-pass-arguments-within-docker-compose) – Auzias Mar 04 '16 at 13:30
  • http://stackoverflow.com/questions/34322631/how-to-pass-arguments-within-docker-compose is a different issue - I want to pass arguments to the command option. – Slenny Mar 04 '16 at 14:49

1 Answers1

6

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.

Erik Dannenberg
  • 5,716
  • 2
  • 16
  • 21
  • 4
    But how can I start a docker-compose with values passed in? – Pille Jul 07 '16 at 20:09
  • 2
    For `docker-compose up` you only have [variable substitution](https://docs.docker.com/compose/compose-file/#variable-substitution) and the [env-file](https://docs.docker.com/compose/env-file/). For `run` you can also use `-e` like with `docker run`. – Erik Dannenberg Jul 08 '16 at 01:35
  • I think this is actually possible now. See https://stackoverflow.com/a/49928257/3757322 – joshmcode Apr 19 '18 at 18:59