From aa00520fc8bb4e04c37c2eb41f3bc3558deab533 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 7 Jun 2016 14:11:11 +0200 Subject: [PATCH] Fix create command flags Any command that expects extra flags after positional args needs to set flags.SetInterspersed(false). Signed-off-by: Vincent Demeester --- api/client/container/create.go | 2 ++ integration-cli/docker_cli_create_test.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/client/container/create.go b/api/client/container/create.go index 70290fcc51..5038324a2b 100644 --- a/api/client/container/create.go +++ b/api/client/container/create.go @@ -46,6 +46,8 @@ func NewCreateCommand(dockerCli *client.DockerCli) *cobra.Command { cmd.SetFlagErrorFunc(flagErrorFunc) flags := cmd.Flags() + flags.SetInterspersed(false) + flags.StringVar(&opts.name, "name", "", "Assign a name to the container") // Add an explicit help that doesn't have a `-h` to prevent the conflict diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go index 9649482414..ed76353aae 100644 --- a/integration-cli/docker_cli_create_test.go +++ b/integration-cli/docker_cli_create_test.go @@ -25,7 +25,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) { if daemonPlatform == "windows" { c.Skip("Fails on Windows CI") } - out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space") + out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags") cleanedContainerID := strings.TrimSpace(out) @@ -47,7 +47,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) { c.Assert(string(cont.Path), checker.Equals, "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path)) b := false - expected := []string{"arg1", "arg2", "arg with space"} + expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"} for i, arg := range expected { if arg != cont.Args[i] { b = true