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

During
“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/my_script.sh

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

Step 2/5: RUN cat /home/my_script.sh
—> Running in x3f3ds9ef37d
#!/bin/sh
MYVARIABLE=helloworld
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’

Hi,
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.