Home Send variables into docker container to use in a script
Reply: 0

Send variables into docker container to use in a script

user1317 Published in April 25, 2018, 8:23 am

I am running a script in the CI/CD of the pipeline. The goal is to get a string to work with.
When I get that result, I save it into a variable and save result in the yaml file of the dockerfile.

I am wanting to pass that variable from the CI environment, into the docker-compose container. So, I am trying to export this like another things are exported, however it doesn't work:

LOG="$(cat ".log")"
export LOG

I have added a variables.env file that looks like this:


And then modified the docker-compose.yaml to read the var :

pdf: image: thisimage/this build: context: ../ dockerfile: ./docker/Dockerfile.name args: git_branch: ${GIT_BRANCH} env_file: - variables.env environment: - LOG=${LOG} volumes: - do-build:/src/do-build

And in the script that finally runs the docker-container, I have also Declared it: FROM ubuntu:16.04 as pdf-builder

ARG log
ENV log=${log}
RUN LOG=${log}
RUN export $LOG

And right after, I run the script.sh that requires the variable, however, it returns Unbound variable and breaks.

echo ${LOG}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.410782 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO