If I run
FOO=bar docker run -it -e FOO=$FOO debian env
That environment variable is not persistedset in my environmentthe command output for later commandsthe env command.
echo $FOOPATH=/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 always available until I unset FOOfrom the container and also exported into my current shell environment.
echo $FOO
bar
unset FOO
echo $FOO
I expect this behavior with export FOO=bar but why does that happen with ; too?