Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: Run on a work node of kubernetes. Containers are killed, instead of exiting normally. Some resources are not released such as vips created by keepalived. What you expected to happen: The container exits properly so that system resources are released correctly How to reproduce it (as minimally and precisely as possible): Anything else we need to know?: , line 139: Can I try to stop containers before removing them? Environment: Kubernetes version (use ): v1.18.5 Cloud provider or hardware configuration: OS (e.g: ): CentOS 7.4.1708 Kernel (e.g. ): 3.10.0-1127.18.2.el7.x86_64 Install tools: kubeadm
/sig cluster-lifecycle These SIGs are my best guesses for this issue. Please comment if I am incorrect about one. I am a bot run by vllry. ‍
/area kubeadm /remove-kind bug /kind feature there is some discussion / Qs on the PR.

Discussion:
func (runtime *DockerRuntime) RemoveContainers(containers []string) error { errs := []error{} for _, container := range containers { <del> out, err := runtime.exec.Command("docker", "rm", "--force", "--volumes", container).CombinedOutput() </del> <ins> out, err := runtime.exec.Command("docker", "stop", container).CombinedOutput() </ins> if err != nil { // don't stop on errors, try to remove as many containers as possible <del> errs = append(errs, errors.Wrapf(err, "failed to remove running container %s: output: %s, error", container, string(out))) </del> <ins> errs = append(errs, errors.Wrapf(err, "failed to stop running container %s: output: %s, error", container, string(out))) } else { out, err = runtime.exec.Command("docker", "rm", "--volumes", container).CombinedOutput() if err != nil { errs = append(errs, errors.Wrapf(err, "failed to remove running container %s: output: %s, error", container, string(out))) } </ins> } } return errorsutil.NewAggregate(errs)

fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, // Test case 1 fakeOK, fakeOK, fakeOK, fakeErr, fakeOK, fakeOK, fakeErr, fakeOK, fakeOK, fakeErr, fakeOK, <del> fakeOK, fakeOK, fakeOK, fakeOK, fakeErr, fakeOK, </del> <ins> fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, fakeOK, fakeErr, fakeOK, fakeOK, fakeErr, fakeOK, fakeOK, fakeErr, fakeOK, </ins> }, } execer := fakeexec.FakeExec{

{"invalid: CRI rmp failure", "unix:///var/run/crio/crio.sock", []string{"k8s_p1", "k8s_p2", "k8s_p3"}, true}, {"invalid: CRI stopp failure", "unix:///var/run/crio/crio.sock", []string{"k8s_p1", "k8s_p2", "k8s_p3"}, true}, {"valid: remove containers using docker", constants.DefaultDockerCRISocket, []string{"k8s_c1", "k8s_c2", "k8s_c3"}, false}, <del> {"invalid: remove containers using docker", constants.DefaultDockerCRISocket, []string{"k8s_c1", "k8s_c2", "k8s_c3"}, true}, </del> <ins> {"invalid: docker rm failure", constants.DefaultDockerCRISocket, []string{"k8s_c1", "k8s_c2", "k8s_c3"}, true}, {"invalid: docker stop failure", constants.DefaultDockerCRISocket, []string{"k8s_c1", "k8s_c2", "k8s_c3"}, true}, </ins> } for _, tc := range cases {