DotCi icon indicating copy to clipboard operation
DotCi copied to clipboard

In docker builds, dotci will prematurely evaluate shell logic specified in .ci.yml

Open michaelstandley opened this issue 10 years ago • 2 comments

If you have something like this in your .ci.yml:

command:
  - echo $HOSTNAME

Instead of giving you the hostname from inside the docker container as expected, it will evaluate the shell variable outside the docker container and give you the hostname of the docker server. We want shell logic to be evaluated at the right time, which is inside the docker container.

To do this you will need to assemble the "docker run" command line call in this way:

DOCKER_COMMAND=`cat << "EOF"
echo stuff from .ci.yml goes in here
echo $HOSTNAME
EOF`

And then once DOCKER_COMMAND is set, run the container like this:

docker run [options-from-ci-yml] [image-from-ci-yml] bash -c "$DOCKER_COMMAND"

NB: this shadows another issue which will need to be addressed once this is implemented: environment variables set by dotci are not forwarded to the docker container. Any shell variable that dotci sets (and which could potentially be used in the context of a .ci.yml) must be manually forwarded to the docker container at runtime using the -e flag for docker run.

michaelstandley avatar Jan 19 '15 18:01 michaelstandley

+1

dinoshauer avatar Feb 13 '15 14:02 dinoshauer

Did you find a workaround to this?

cnuss avatar Oct 01 '15 21:10 cnuss