I want to run echo "tools path is: $TOOLSPATH"
in my docker image but make sure the variable doesn’t get expanded in my machine and sent to docker. I am not sure how to avoid variable expansion.
docker run -v `pwd`:/root -it --rm foobar echo 'tools path is: $TOOLSPATH'
> tools path is: $TOOLSPATH
docker run -v `pwd`:/root -it --rm foobar echo "tools path is: $TOOLSPATH"
> tools path is:
2
Answers
There is one way to run
echo $VAR
inside the container and print it in your terminal. You just need to pass an interpreter too.PS: I used
alpine
as a test. Ifsh
doesn’t work, you can trybash
instead.This might be helpful to you