Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 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
...
like image 681
Slenny Avatar asked Oct 18 '25 13:10

Slenny


1 Answers

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.

like image 62
Erik Dannenberg Avatar answered Oct 21 '25 03:10

Erik Dannenberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!