HCS provides two functions to stop a container:
HcsShutdownComputeSystem is used first, and attempts to gracefully stop the container.
HcsTerminateComputeSystem is used if shutdown fails, and force stops the container.
moby uses hcsshim.IsAlreadyStopped to check if the error returned from HcsShutdownComputeSystem indicates that the container has already terminated, and only calls HcsTerminateComputeSystem if it is still running. However, due to a bug in hcsshim.IsAlreadyStopped, this function returned true if the error was ERROR_PROC_NOT_FOUND, which can be returned even if the container is left running. When this happened, moby would effectively leak the container, leaving it running in HCS, but assuming from moby's point of view that it had stopped.
HCS provides two functions to stop a container:
HcsShutdownComputeSystemis used first, and attempts to gracefully stop the container.HcsTerminateComputeSystemis used if shutdown fails, and force stops the container.moby uses
hcsshim.IsAlreadyStoppedto check if the error returned fromHcsShutdownComputeSystemindicates that the container has already terminated, and only callsHcsTerminateComputeSystemif it is still running. However, due to a bug inhcsshim.IsAlreadyStopped, this function returnedtrueif the error wasERROR_PROC_NOT_FOUND, which can be returned even if the container is left running. When this happened, moby would effectively leak the container, leaving it running in HCS, but assuming from moby's point of view that it had stopped.