Exec: Add ability to set environment variables

Keeping the current behavior for exec, i.e., inheriting
variables from main process. New variables will be added
to current ones. If there's already a variable with that
name it will be overwritten.

Example of usage: docker exec -it -e TERM=vt100 <container> top

Closes #24355.

Signed-off-by: Jonh Wendell <jonh.wendell@redhat.com>
This commit is contained in:
Jonh Wendell 2016-07-13 14:24:41 -03:00 committed by Tibor Vass
parent 38d93769fe
commit 73dd34b2b3
4 changed files with 10 additions and 1 deletions

View File

@ -1277,7 +1277,7 @@ _docker_exec() {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--detach -d --detach-keys --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--detach -d --detach-keys -e --env --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) )
;; ;;
*) *)
__docker_complete_containers_running __docker_complete_containers_running

View File

@ -1679,6 +1679,7 @@ __docker_subcommand() {
$opts_help \ $opts_help \
$opts_attach_exec_run_start \ $opts_attach_exec_run_start \
"($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
"($help -e --env)"{-e,--env}"[Set environment variables]" \
"($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \ "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \
"($help)--privileged[Give extended Linux capabilities to the command]" \ "($help)--privileged[Give extended Linux capabilities to the command]" \
"($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \ "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \

View File

@ -14,6 +14,7 @@ Run a command in a running container
Options: Options:
-d, --detach Detached mode: run command in the background -d, --detach Detached mode: run command in the background
--detach-keys Override the key sequence for detaching a container --detach-keys Override the key sequence for detaching a container
-e, --env=[] Set environment variables
--help Print usage --help Print usage
-i, --interactive Keep STDIN open even if not attached -i, --interactive Keep STDIN open even if not attached
--privileged Give extended privileges to the command --privileged Give extended privileges to the command

View File

@ -8,6 +8,7 @@ docker-exec - Run a command in a running container
**docker exec** **docker exec**
[**-d**|**--detach**] [**-d**|**--detach**]
[**--detach-keys**[=*[]*]] [**--detach-keys**[=*[]*]]
[**-e**|**--env**[=*[]*]]
[**--help**] [**--help**]
[**-i**|**--interactive**] [**-i**|**--interactive**]
[**--privileged**] [**--privileged**]
@ -32,6 +33,12 @@ container is unpaused, and then run
**--detach-keys**="" **--detach-keys**=""
Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
**-e**, **--env**=[]
Set environment variables
This option allows you to specify arbitrary environment variables that are
available for the command to be executed.
**--help** **--help**
Print usage statement Print usage statement