In my docker-compose I have a command
like this:
version: "3.9"
...
command: "/bin/sh -c 'max=20; min=10; trap exit TERM; while :; do echo test; sleep $(($RANDOM%($max-$min+1)+$min)); done"
...
It prints test
with intervals between 10 and 20 seconds. In my terminal this works just fine. In docker-compose it has issues:
WARN[0000] The "RANDOM" variable is not set. Defaulting to a blank string.
WARN[0000] The "max" variable is not set. Defaulting to a blank string.
WARN[0000] The "min" variable is not set. Defaulting to a blank string.
WARN[0000] The "min" variable is not set. Defaulting to a blank string.
WARN[0000] /..../dist/docker-compose.yml: `version` is obsolete
1 error(s) decoding:
* error decoding 'services[tool].command': invalid command line string
It seems to have issues with these bash variables. Is there a way to fix this?