Skip to content

Commit

Permalink
Fixes docker#10388
Browse files Browse the repository at this point in the history
The cmd.Lookup should be "-attach" and not "attach", as seen in
docker/docker/runconfig/parse.go

Signed-off-by: André Martins <[email protected]>
  • Loading branch information
aanm committed Feb 2, 2015
1 parent 0d5a1cb commit af90fe6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/client/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
return err
}
} else {
if fl := cmd.Lookup("attach"); fl != nil {
if fl := cmd.Lookup("-attach"); fl != nil {
flAttach = fl.Value.(*opts.ListOpts)
if flAttach.Len() != 0 {
return ErrConflictAttachDetach
Expand Down
17 changes: 17 additions & 0 deletions integration-cli/docker_cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,23 @@ func TestRunAttachStdOutAndErrTTYMode(t *testing.T) {
logDone("run - Attach stderr and stdout with -t")
}

// Test for #10388 - this will run the same test as TestRunAttachStdOutAndErrTTYMode
// but using --attach instead of -a to make sure we read the flag correctly
func TestRunAttachWithDettach(t *testing.T) {
defer deleteAllContainers()

cmd := exec.Command(dockerBinary, "run", "-d", "--attach", "stdout", "busybox", "true")

_, stderr, _, err := runCommandWithStdoutStderr(cmd)
if err == nil {
t.Fatalf("Container should have exited with error code different than 0", err)
} else if !strings.Contains(stderr, "Conflicting options: -a and -d") {
t.Fatalf("Should have been returned an error with conflicting options -a and -d")
}

logDone("run - Attach stdout with -d")
}

func TestRunState(t *testing.T) {
defer deleteAllContainers()
cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
Expand Down

0 comments on commit af90fe6

Please sign in to comment.