Docker exec quoting variables

Ok, I found a way to do it, all you need to do is evaluate command with bash

docker exec -it <container id> bash -c 'echo something-${CLI}'

returns something-/usr/local/bin/myprogram

If the CLI environment variable is not already set in the container, you can also pass it in such as:

docker exec -it -e CLI=/usr/local/bin/myprogram <container id> bash -c 'echo something-${CLI}'

See the help file:

 docker exec --help

 Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

 Run a command in a running container

Options:
-d, --detach               Detached mode: run command in the background
-e, --env list             Set environment variables
....