diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index fccd89eb5e..6201c2bd2e 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -19,8 +19,8 @@ import ( "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" servicecmd "github.com/docker/docker/cli/command/service" - runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/docker/opts" + runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/go-connections/nat" ) @@ -85,7 +85,12 @@ func runDeploy(dockerCli *command.DockerCli, opts deployOptions) error { ctx := context.Background() namespace := namespace{name: opts.namespace} - if err := createNetworks(ctx, dockerCli, config.Networks, namespace); err != nil { + + networks := config.Networks + if networks == nil { + networks = make(map[string]composetypes.NetworkConfig) + } + if err := createNetworks(ctx, dockerCli, networks, namespace); err != nil { return err } return deployServices(ctx, dockerCli, config, namespace, opts.sendRegistryAuth) diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index 3e7f20692a..768f7ddd80 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -141,7 +141,6 @@ func (c *containerConfig) config() *enginecontainer.Config { Labels: c.labels(), Tty: c.spec().TTY, User: c.spec().User, - Hostname: c.spec().Hostname, Env: c.spec().Env, Hostname: c.spec().Hostname, WorkingDir: c.spec().Dir, diff --git a/integration-cli/docker_cli_stack_test.go b/integration-cli/docker_cli_stack_test.go index db4fdfc1b4..76ce78c54f 100644 --- a/integration-cli/docker_cli_stack_test.go +++ b/integration-cli/docker_cli_stack_test.go @@ -1,9 +1,6 @@ package main import ( - "io/ioutil" - "os" - "github.com/docker/docker/pkg/integration/checker" "github.com/go-check/check" ) @@ -41,72 +38,26 @@ func (s *DockerSwarmSuite) TestStackServices(c *check.C) { c.Assert(out, check.Equals, "Nothing found in stack: UNKNOWN_STACK\n") } -// testDAB is the DAB JSON used for testing. -// TODO: Use template/text and substitute "Image" with the result of -// `docker inspect --format '{{index .RepoDigests 0}}' busybox:latest` -const testDAB = `{ - "Version": "0.1", - "Services": { - "srv1": { - "Image": "busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0", - "Command": ["top"] - }, - "srv2": { - "Image": "busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0", - "Command": ["tail"], - "Args": ["-f", "/dev/null"] - } - } -}` - -func (s *DockerSwarmSuite) TestStackWithDAB(c *check.C) { +func (s *DockerSwarmSuite) TestStackDeployComposeFile(c *check.C) { testRequires(c, ExperimentalDaemon) - // setup - testStackName := "test" - testDABFileName := testStackName + ".dab" - defer os.RemoveAll(testDABFileName) - err := ioutil.WriteFile(testDABFileName, []byte(testDAB), 0444) - c.Assert(err, checker.IsNil) d := s.AddDaemon(c, true, true) - // deploy - stackArgs := []string{"stack", "deploy", testStackName} + + testStackName := "testdeploy" + stackArgs := []string{ + "stack", "deploy", + "--compose-file", "fixtures/deploy/default.yaml", + testStackName, + } out, err := d.Cmd(stackArgs...) + c.Assert(err, checker.IsNil, check.Commentf(out)) + + out, err = d.Cmd([]string{"stack", "ls"}...) c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, "Loading bundle from test.dab\n") - c.Assert(out, checker.Contains, "Creating service test_srv1\n") - c.Assert(out, checker.Contains, "Creating service test_srv2\n") - // ls - stackArgs = []string{"stack", "ls"} - out, err = d.Cmd(stackArgs...) + c.Assert(out, check.Equals, "NAME SERVICES\n"+"testdeploy 2\n") + + out, err = d.Cmd([]string{"stack", "rm", testStackName}...) c.Assert(err, checker.IsNil) - c.Assert(out, check.Equals, "NAME SERVICES\n"+"test 2\n") - // rm - stackArgs = []string{"stack", "rm", testStackName} - out, err = d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, "Removing service test_srv1\n") - c.Assert(out, checker.Contains, "Removing service test_srv2\n") - // ls (empty) - stackArgs = []string{"stack", "ls"} - out, err = d.Cmd(stackArgs...) + out, err = d.Cmd([]string{"stack", "ls"}...) c.Assert(err, checker.IsNil) c.Assert(out, check.Equals, "NAME SERVICES\n") } - -func (s *DockerSwarmSuite) TestStackWithDABExtension(c *check.C) { - testRequires(c, ExperimentalDaemon) - // setup - testStackName := "test.dab" - testDABFileName := testStackName - defer os.RemoveAll(testDABFileName) - err := ioutil.WriteFile(testDABFileName, []byte(testDAB), 0444) - c.Assert(err, checker.IsNil) - d := s.AddDaemon(c, true, true) - // deploy - stackArgs := []string{"stack", "deploy", testStackName} - out, err := d.Cmd(stackArgs...) - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, "Loading bundle from test.dab\n") - c.Assert(out, checker.Contains, "Creating service test_srv1\n") - c.Assert(out, checker.Contains, "Creating service test_srv2\n") -} diff --git a/integration-cli/fixtures/deploy/default.yaml b/integration-cli/fixtures/deploy/default.yaml new file mode 100644 index 0000000000..f30c04f8f1 --- /dev/null +++ b/integration-cli/fixtures/deploy/default.yaml @@ -0,0 +1,9 @@ + +version: "3" +services: + web: + image: busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0 + command: top + db: + image: busybox@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0 + command: "tail -f /dev/null"