Docker pass variable without it getting expanded

Solution 1:

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.

docker run alpine sh -c 'echo my HOME: $HOME'
my HOME: /root

PS: I used alpine as a test. If sh doesn't work, you can try bash instead.