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>
Upstream-commit: e03bf1221ee2c863f25a57af4d415e2d8ff4f26c
Component: engine
This commit is contained in:
Jonh Wendell
2016-07-13 14:24:41 -03:00
parent e4a5c6f7fb
commit bf1e1cd730
10 changed files with 46 additions and 5 deletions

View File

@ -45,7 +45,7 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly
sp := spec.Process
sp.Args = specp.Args
sp.Terminal = specp.Terminal
if specp.Env != nil {
if len(specp.Env) > 0 {
sp.Env = specp.Env
}
if specp.Cwd != nil {