diff --git a/daemon/images/image_list.go b/daemon/images/image_list.go index 2686b3f8f5..8ab56a6820 100644 --- a/daemon/images/image_list.go +++ b/daemon/images/image_list.go @@ -2,6 +2,7 @@ package images // import "github.com/docker/docker/daemon/images" import ( "context" + "errors" "fmt" "sort" "time" @@ -132,7 +133,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) if err != nil { // The layer may have been deleted between the call to `Map()` or // `Heads()` and the call to `Get()`, so we just ignore this error - if err == layer.ErrLayerDoesNotExist { + if errors.Is(err, layer.ErrLayerDoesNotExist) { continue } return nil, err diff --git a/image/store.go b/image/store.go index ccd8f00fd4..c457bc3a82 100644 --- a/image/store.go +++ b/image/store.go @@ -88,7 +88,7 @@ func (is *store) restore() error { } l, err = is.lss.Get(chainID) if err != nil { - if err == layer.ErrLayerDoesNotExist { + if errors.Is(err, layer.ErrLayerDoesNotExist) { logrus.WithFields(f{"chainID": chainID, "os": img.OperatingSystem(), "err": err}).Error("not restoring image") return nil } diff --git a/layer/layer_test.go b/layer/layer_test.go index 8eeb90f8df..41848576f9 100644 --- a/layer/layer_test.go +++ b/layer/layer_test.go @@ -2,6 +2,7 @@ package layer // import "github.com/docker/docker/layer" import ( "bytes" + "errors" "io" "os" "path/filepath" @@ -397,7 +398,7 @@ func TestStoreRestore(t *testing.T) { // Create again with same name, should return error if _, err := ls2.CreateRWLayer("some-mount_name", layer3b.ChainID(), nil); err == nil { t.Fatal("Expected error creating mount with same name") - } else if err != ErrMountNameConflict { + } else if !errors.Is(err, ErrMountNameConflict) { t.Fatal(err) }