FOO=bar docker run -it -e FOO=$FOO debian env
Here the $FOO from FOO=$FOO will be expanded before the FOO=bar assignment happens.
You can check that with a more straight-forward example:
FOO=first
FOO=second echo FOO=$FOO
=> FOO=first
FOO=third; echo FOO=$FOO
=> FOO=third
The FOO=bar cmd form will really set FOO=bar in the environment of cmd, but a command like docker does not automatically export its own environment into the container, but the environment vars have to be added explicitly with the -e switch.
Again, a more straightforward demo would be:
FOO=before
FOO=after env - FOO=$FOO printenv FOO
=> before