diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 221b8dcd7f..3534b145c3 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -738,3 +738,29 @@ func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *check.C) { out, _ := dockerCmd(c, "network", "create", "one") dockerCmd(c, "run", "-d", "--net", strings.TrimSpace(out), "busybox", "top") } + +func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *check.C) { + testRequires(c, DaemonIsLinux, NotUserNamespace) + s.d.Start() + + // Run a few containers on host network + for i := 0; i < 10; i++ { + cName := fmt.Sprintf("hostc-%d", i) + out, err := s.d.Cmd("run", "-d", "--name", cName, "--net=host", "--restart=always", "busybox", "top") + c.Assert(err, checker.IsNil, check.Commentf(out)) + } + + // Kill daemon ungracefully and restart + if err := s.d.cmd.Process.Kill(); err != nil { + c.Fatal(err) + } + s.d.Restart() + + // make sure all the containers are up and running + for i := 0; i < 10; i++ { + cName := fmt.Sprintf("hostc-%d", i) + runningOut, err := s.d.Cmd("inspect", "--format='{{.State.Running}}'", cName) + c.Assert(err, checker.IsNil) + c.Assert(strings.TrimSpace(runningOut), checker.Equals, "true") + } +}