From a03989227c380e7c4495eb84002f8e1eaa06e984 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 27 Mar 2014 19:11:23 +0000 Subject: [PATCH 1/2] add test Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) Upstream-commit: 366f084eb0864db6dcf5cc47e434b3c6f43500d7 Component: engine --- .../engine/integration/commands_test.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/engine/integration/commands_test.go b/components/engine/integration/commands_test.go index 5b967b68cc..7164cc5af7 100644 --- a/components/engine/integration/commands_test.go +++ b/components/engine/integration/commands_test.go @@ -1163,3 +1163,27 @@ func TestCmdKill(t *testing.T) { closeWrap(stdin, stdinPipe, stdout, stdoutPipe) } + +func TestRunTTYCommitRun(t *testing.T) { + cli := api.NewDockerCli(nil, ioutil.Discard, ioutil.Discard, testDaemonProto, testDaemonAddr, nil) + + defer cleanup(globalEngine, t) + + ch := make(chan struct{}) + go func() { + defer close(ch) + cli.CmdRun("-t", unitTestImageID, "/bin/ls") + }() + + container := waitContainerStart(t, 10*time.Second) + time.Sleep(500 * time.Millisecond) + setTimeout(t, "Waiting for container timedout", 5*time.Second, func() { + <-ch + }) + + cli.CmdCommit(container.ID, "ttytest") + + if err := cli.CmdRun("ttytest", "/bin/ls"); err != nil { + t.Fatal(err) + } +} From 8003cf19d2089d8d3a4c850f9394ec5080df5245 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 27 Mar 2014 19:16:03 +0000 Subject: [PATCH 2/2] do not merge -i or -t options Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) Upstream-commit: 2c8b63cb754128a64083426e5c3e6016118e78df Component: engine --- .../integration-cli/docker_cli_commit_test.go | 21 +++++++++++ .../engine/integration/commands_test.go | 37 ++++--------------- components/engine/runconfig/merge.go | 9 ----- 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_commit_test.go b/components/engine/integration-cli/docker_cli_commit_test.go index e99379231e..7635add913 100644 --- a/components/engine/integration-cli/docker_cli_commit_test.go +++ b/components/engine/integration-cli/docker_cli_commit_test.go @@ -62,3 +62,24 @@ func TestCommitNewFile(t *testing.T) { logDone("commit - commit file and read") } + +func TestCommitTTY(t *testing.T) { + cmd := exec.Command(dockerBinary, "run", "-t", "--name", "tty", "busybox", "/bin/ls") + + if _, err := runCommand(cmd); err != nil { + t.Fatal(err) + } + + cmd = exec.Command(dockerBinary, "commit", "tty", "ttytest") + imageId, _, err := runCommandWithOutput(cmd) + if err != nil { + t.Fatal(err) + } + imageId = strings.Trim(imageId, "\r\n") + + cmd = exec.Command(dockerBinary, "run", "ttytest", "/bin/ls") + + if _, err := runCommand(cmd); err != nil { + t.Fatal(err) + } +} diff --git a/components/engine/integration/commands_test.go b/components/engine/integration/commands_test.go index 7164cc5af7..b91ba603a7 100644 --- a/components/engine/integration/commands_test.go +++ b/components/engine/integration/commands_test.go @@ -3,12 +3,6 @@ package docker import ( "bufio" "fmt" - "github.com/dotcloud/docker/api/client" - "github.com/dotcloud/docker/daemon" - "github.com/dotcloud/docker/engine" - "github.com/dotcloud/docker/image" - "github.com/dotcloud/docker/pkg/term" - "github.com/dotcloud/docker/utils" "io" "io/ioutil" "os" @@ -19,6 +13,13 @@ import ( "syscall" "testing" "time" + + "github.com/dotcloud/docker/api/client" + "github.com/dotcloud/docker/daemon" + "github.com/dotcloud/docker/engine" + "github.com/dotcloud/docker/image" + "github.com/dotcloud/docker/pkg/term" + "github.com/dotcloud/docker/utils" ) func closeWrap(args ...io.Closer) error { @@ -1163,27 +1164,3 @@ func TestCmdKill(t *testing.T) { closeWrap(stdin, stdinPipe, stdout, stdoutPipe) } - -func TestRunTTYCommitRun(t *testing.T) { - cli := api.NewDockerCli(nil, ioutil.Discard, ioutil.Discard, testDaemonProto, testDaemonAddr, nil) - - defer cleanup(globalEngine, t) - - ch := make(chan struct{}) - go func() { - defer close(ch) - cli.CmdRun("-t", unitTestImageID, "/bin/ls") - }() - - container := waitContainerStart(t, 10*time.Second) - time.Sleep(500 * time.Millisecond) - setTimeout(t, "Waiting for container timedout", 5*time.Second, func() { - <-ch - }) - - cli.CmdCommit(container.ID, "ttytest") - - if err := cli.CmdRun("ttytest", "/bin/ls"); err != nil { - t.Fatal(err) - } -} diff --git a/components/engine/runconfig/merge.go b/components/engine/runconfig/merge.go index 1240dbcacd..252a2fe434 100644 --- a/components/engine/runconfig/merge.go +++ b/components/engine/runconfig/merge.go @@ -65,15 +65,6 @@ func Merge(userConf, imageConf *Config) error { } } - if !userConf.Tty { - userConf.Tty = imageConf.Tty - } - if !userConf.OpenStdin { - userConf.OpenStdin = imageConf.OpenStdin - } - if !userConf.StdinOnce { - userConf.StdinOnce = imageConf.StdinOnce - } if userConf.Env == nil || len(userConf.Env) == 0 { userConf.Env = imageConf.Env } else {