builder/dockerfile: containerManager.RemoveAll() prevent partial cleanup
Prevent cleanup from terminating early when failing to remove a container; - continue trying to remove remaining containers - ignore errors due to containers that were not found Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
03a8188a9a
commit
0aa96c5512
1 changed files with 3 additions and 2 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/builder"
|
||||
containerpkg "github.com/docker/docker/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -128,9 +129,9 @@ func (e *statusCodeError) StatusCode() int {
|
|||
// RemoveAll containers managed by this container manager
|
||||
func (c *containerManager) RemoveAll(stdout io.Writer) {
|
||||
for containerID := range c.tmpContainers {
|
||||
if err := c.backend.ContainerRm(containerID, &backend.ContainerRmConfig{ForceRemove: true, RemoveVolume: true}); err != nil {
|
||||
if err := c.backend.ContainerRm(containerID, &backend.ContainerRmConfig{ForceRemove: true, RemoveVolume: true}); err != nil && !errdefs.IsNotFound(err) {
|
||||
_, _ = fmt.Fprintf(stdout, "Removing intermediate container %s: %v\n", stringid.TruncateID(containerID), err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
delete(c.tmpContainers, containerID)
|
||||
_, _ = fmt.Fprintf(stdout, " ---> Removed intermediate container %s\n", stringid.TruncateID(containerID))
|
||||
|
|
Loading…
Add table
Reference in a new issue