diff --git a/internal/storage/image.go b/internal/storage/image.go index 706574b7b30..cc3977a3ec1 100644 --- a/internal/storage/image.go +++ b/internal/storage/image.go @@ -93,6 +93,9 @@ type imageService struct { ctx context.Context } +// ImageBeingPulled map[string]bool to keep track of the images haven't done pulling. +var ImageBeingPulled sync.Map + // CgroupPullConfiguration type CgroupPullConfiguration struct { UseNewCgroup bool @@ -316,6 +319,19 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s } results, err = svc.appendCachedResult(systemContext, ref, image, results, newImageCache) if err != nil { + // skip reporting errors if the images haven't finished pulling + if os.IsNotExist(errors.Cause(err)) { + donePulling := true + for _, name := range image.Names { + if _, ok := ImageBeingPulled.Load(name); ok { + donePulling = false + break + } + } + if !donePulling { + continue + } + } return nil, err } } diff --git a/server/image_pull.go b/server/image_pull.go index 2e600af81b1..b463029f38a 100644 --- a/server/image_pull.go +++ b/server/image_pull.go @@ -69,6 +69,7 @@ func (s *Server) PullImage(ctx context.Context, req *types.PullImageRequest) (*t if !inProgress { pullOp = &pullOperation{} s.pullOperationsInProgress[pullArgs] = pullOp + storage.ImageBeingPulled.Store(pullArgs.image, true) pullOp.wg.Add(1) } return pullOp, inProgress @@ -79,6 +80,7 @@ func (s *Server) PullImage(ctx context.Context, req *types.PullImageRequest) (*t defer func() { s.pullOperationsLock.Lock() delete(s.pullOperationsInProgress, pullArgs) + storage.ImageBeingPulled.Delete(pullArgs.image) pullOp.wg.Done() s.pullOperationsLock.Unlock() }()