Compose: Ask conditional docker-compose multiple exist

Created on 20 Mar 2017  路  1Comment  路  Source: docker/compose

Hi,

I'm trying to do a docker-compose.yml with conditional flow.
It is posibble?
An example is for example a command tag.
With an image entrypoint:
ENTRYPOINT ["/usr/bin/mibinprocess"]

Then in the docker-compose.yml:
...
command: -param1 ${MIPARAM1}
...

But if need to use other params, howto describe this?
...
if a condition then use:
command: -param1 ${MIPARAM1}
else use:
command: -param1 ${MIPARAM1} -param2 ${MIPARAM2}
...

Regards

kinquestion

Most helpful comment

I'm afraid that's outside the scope of docker-compose.
Although you can probably write

command: ${COMMAND_PARAMS}

in your docker-compose.yml file, and start it with a 5-line bash script

#!/bin/bash
if test -z $CONDITION; then
  params="-param1 ${MIPARAM1}"
else
  params="-param1 ${MIPARAM1} -param2 ${MIPARAM2}"
fi
COMMAND_PARAMS=$params docker-compose up

>All comments

I'm afraid that's outside the scope of docker-compose.
Although you can probably write

command: ${COMMAND_PARAMS}

in your docker-compose.yml file, and start it with a 5-line bash script

#!/bin/bash
if test -z $CONDITION; then
  params="-param1 ${MIPARAM1}"
else
  params="-param1 ${MIPARAM1} -param2 ${MIPARAM2}"
fi
COMMAND_PARAMS=$params docker-compose up
Was this page helpful?
0 / 5 - 0 ratings