diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index b419878001..86508f9384 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -233,8 +233,8 @@ func KillContainer(w http.ResponseWriter, r *http.Request) { return } if sig == 0 || syscall.Signal(sig) == syscall.SIGKILL { - var opts entities.WaitOptions - if _, err := containerEngine.ContainerWait(r.Context(), []string{name}, opts); err != nil { + if _, err := utils.WaitContainer(w, r); err != nil { + utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err) return } diff --git a/test/python/docker/test_containers.py b/test/python/docker/test_containers.py index 01e049ed46..5c2a5fef2a 100644 --- a/test/python/docker/test_containers.py +++ b/test/python/docker/test_containers.py @@ -95,6 +95,15 @@ def test_stop_container(self): top.reload() self.assertIn(top.status, ("stopped", "exited")) + def test_kill_container(self): + top = self.client.containers.get(TestContainers.topContainerId) + self.assertEqual(top.status, "running") + + # Kill a running container and validate the state + top.kill() + top.reload() + self.assertIn(top.status, ("stopped", "exited")) + def test_restart_container(self): # Validate the container state top = self.client.containers.get(TestContainers.topContainerId)