mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
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:
@ -119,6 +119,17 @@ func (s *DockerSuite) TestExecEnv(c *check.C) {
|
||||
c.Assert(out, checker.Contains, "HOME=/root")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestExecSetEnv(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
runSleepingContainer(c, "-e", "HOME=/root", "-d", "--name", "testing")
|
||||
c.Assert(waitRun("testing"), check.IsNil)
|
||||
|
||||
out, _ := dockerCmd(c, "exec", "-e", "HOME=/another", "-e", "ABC=xyz", "testing", "env")
|
||||
c.Assert(out, checker.Not(checker.Contains), "HOME=/root")
|
||||
c.Assert(out, checker.Contains, "HOME=/another")
|
||||
c.Assert(out, checker.Contains, "ABC=xyz")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestExecExitStatus(c *check.C) {
|
||||
runSleepingContainer(c, "-d", "--name", "top")
|
||||
|
||||
|
Reference in New Issue
Block a user