From ba62de1350b25ec1d85eff67bd3c8c5be98d02a7 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Thu, 17 Mar 2022 20:18:30 +0800 Subject: [PATCH] docker: fix "endpoint with name container_xx already exists in network none" error --- components/engine/daemon/kill.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/engine/daemon/kill.go b/components/engine/daemon/kill.go index 2652f7ad2..cb0ec61d1 100644 --- a/components/engine/daemon/kill.go +++ b/components/engine/daemon/kill.go @@ -162,7 +162,16 @@ func (daemon *Daemon) Kill(container *containerpkg.Container) error { if isErrNoSuchProcess(err) { // there is a case where we hit here before the exit event is processed // So let's wait the container's stop timeout amount of time to see if the event is eventually processed - container.WaitForState(containerpkg.WaitConditionNotRunning, container.StopTimeout()) + if err := container.WaitForState(containerpkg.WaitConditionNotRunning, container.StopTimeout()); err != nil { + ei := libcontainerd.EventInfo{ + ContainerID: container.ID, + ProcessID: container.ID, + Pid: uint32(container.GetPID()), + ExitCode: 137, + ExitedAt: time.Now(), + } + daemon.ProcessEvent(container.ID, libcontainerd.EventExit, ei) + } return nil } return err -- 2.23.0