If I run
FOO=bar docker run -it -e FOO=$FOO debian env
That environment variable is not set in the command output for the env command.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=03f3b59c0aab
TERM=xterm
FOO=
HOME=/root
But if I run
FOO=bar; docker run -i -t --rm -e FOO=$FOO debian:stable-slim env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=672bfdcde93c
TERM=xterm
FOO=bar
HOME=/root
Then the variable is available from the container and also exported into my current shell environment.
echo $FOO
bar
I expect this behavior with export FOO=bar but why does that happen with ; too?
foo=barthen runecho "$foo"I seebar, are you trying to dofoo=bar some_other_commandin the first example?bashagain. I'll clarify the question with a more concrete example of what I was trying to do.envfor example. A simpleecho "$var"prints the value of a variable (environment or not).-e FOO="$FOO"because-e FOO=$FOOis almost always a bug.