Skip to main content
added 11 characters in body
Source Link
user313992
user313992

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

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

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
added 11 characters in body
Source Link
user313992
user313992

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 straighstraight-forward example:

FOO=first
FOO=second echo FOO=$FOO
 
second=> FOO=first

FOO=third; echo FOO=$FOO
=> FOO=third
third

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 straigh-forward example:

FOO=first
FOO=second echo FOO=$FOO
 
second

FOO=third; echo FOO=$FOO

third

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

Source Link
user313992
user313992

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 straigh-forward example:

FOO=first
FOO=second echo FOO=$FOO

second

FOO=third; echo FOO=$FOO

third