diff --git a/docs/sources/reference/commandline/cli.rst b/docs/sources/reference/commandline/cli.rst index 3d2aac5233..6a473ec461 100644 --- a/docs/sources/reference/commandline/cli.rst +++ b/docs/sources/reference/commandline/cli.rst @@ -1152,6 +1152,7 @@ image is removed. --cidfile="": Write the container ID to the file -d, --detach=false: Detached mode: Run container in the background, print new container id -e, --env=[]: Set environment variables + --envfile="": Read in a line delimited file of ENV variables -h, --hostname="": Container host name -i, --interactive=false: Keep stdin open even if not attached --privileged=false: Give extended privileges to this container @@ -1284,6 +1285,17 @@ This exposes port ``80`` of the container for use within a link without publishing the port to the host system's interfaces. :ref:`port_redirection` explains in detail how to manipulate ports in Docker. +.. code-block:: bash + + $ sudo docker run -e MYVAR1 --env MYVAR2=foo --envfile ./env.list ubuntu bash + +This sets environmental variables to the container. For illustration all three +flags are shown here. Where -e and --env can be repeated, take an environment +variable and value, or if no "=" is provided, then that variable's current +value is passed through (i.e. $MYVAR1 from the host is set to $MYVAR1 in the +container). The --envfile flag takes a filename as an argument and expects each +line to be a VAR=VAL format. + .. code-block:: bash $ sudo docker run --name console -t -i ubuntu bash