code: func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error) {
  	if refOrID == "" { // ie FROM scratch
  		os := runtime.GOOS
  		if opts.Platform != nil {
  			os = opts.Platform.OS
  		}
  		if !system.IsOSSupported(os) {
  			return nil, nil, system.ErrNotSupportedOperatingSystem
  		}
  		layer, err := newROLayerForImage(nil, i.layerStores[os])
  		return nil, layer, err
  	}
  
  	if opts.PullOption != backend.PullOptionForcePull {
  		image, err := i.GetImage(refOrID)
  		if err != nil && opts.PullOption == backend.PullOptionNoPull {
  			return nil, nil, err
  		}
  		// TODO: shouldn't we error out if error is different from "not found" ?
  		if image != nil {
  			if !system.IsOSSupported(image.OperatingSystem()) {
  				return nil, nil, system.ErrNotSupportedOperatingSystem
  			}
  			layer, err := newROLayerForImage(image, i.layerStores[image.OperatingSystem()])
  			return image, layer, err
  		}
  	}
  
  	image, err := i.pullForBuilder(ctx, refOrID, opts.AuthConfig, opts.Output, opts.Platform)
  	if err != nil {
  		return nil, nil, err
  	}
  	if !system.IsOSSupported(image.OperatingSystem()) {
  		return nil, nil, system.ErrNotSupportedOperatingSystem
  	}
  	layer, err := newROLayerForImage(image, i.layerStores[image.OperatingSystem()])
  	return image, layer, err
  }
docs: // GetImageAndReleasableLayer returns an image and releaseable layer for a reference or ID.
  // Every call to GetImageAndReleasableLayer MUST call releasableLayer.Release() to prevent
  // leaking of layers.