Docker Community Forums

Share and learn in the Docker community.

Dose docker build process able to assign an environment via a script?


(Dockerdockergo) #1

“docker build process”, is possible to assign environment variable via a script?
Otherwise, is the “sed” commend limit in “this script”?

/home/my_variable has content, “helloworld” only.

RUN echo "#!/bin/sh\nMYVARIABLE=$(cat /home/my_variable)\nsed -i “s/MYVARIABLE/${MYVARIABLE}/g” /my_target_path/target.txt\n > /home/

This script content definitely has the right content and I also generate the output to check it.

Step 2/5: RUN cat /home/
—> Running in x3f3ds9ef37d
sed -i “s/MYVARIABLE/${MYVARIABLE}/g” /my_target_path/target.txt

But, I get a wrong with this message. I want to know the reason. Thanks.

sed: -e expression #1, char 26: unknown option to `s’

(Dockerdockergo) #2

I found the way to resolve the problem. I change the delimiter to be “:”. I had tried “|”, the vertical line to run. But, it was not woking. Fortunately, I got the “:” to work.

Reply here for everyone to refer this Q&A.