images

package
v20.10.4+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnlyPlatformWithFallback

func OnlyPlatformWithFallback(p specs.Platform) platforms.Matcher

OnlyPlatformWithFallback uses `platforms.Only` with a fallback to handle the case where the platform

being matched does not have a CPU variant.

The reason for this is that CPU variant is not even if the official image config spec as of this writing. See: https://github.com/opencontainers/image-spec/pull/809 Since Docker tends to compare platforms from the image config, we need to handle this case.

Types

type DistributionServices

type DistributionServices struct {
	DownloadManager   distribution.RootFSDownloadManager
	V2MetadataService metadata.V2MetadataService
	LayerStore        layer.Store // TODO: lcow
	ImageStore        image.Store
	ReferenceStore    dockerreference.Store
}

DistributionServices provides daemon image storage services

type ErrImageDoesNotExist

type ErrImageDoesNotExist struct {
	// contains filtered or unexported fields
}

ErrImageDoesNotExist is error returned when no image can be found for a reference.

func (ErrImageDoesNotExist) Error

func (e ErrImageDoesNotExist) Error() string

func (ErrImageDoesNotExist) NotFound

func (e ErrImageDoesNotExist) NotFound()

NotFound implements the NotFound interface

type ImageService

type ImageService struct {
	// contains filtered or unexported fields
}

ImageService provides a backend for image management

func NewImageService

func NewImageService(config ImageServiceConfig) *ImageService

NewImageService returns a new ImageService from a configuration

func (*ImageService) Children

func (i *ImageService) Children(id image.ID) []image.ID

Children returns the children image.IDs for a parent image. called from list.go to filter containers TODO: refactor to expose an ancestry for image.ID?

func (*ImageService) Cleanup

func (i *ImageService) Cleanup()

Cleanup resources before the process is shutdown. called from daemon.go Daemon.Shutdown()

func (*ImageService) CommitBuildStep

func (i *ImageService) CommitBuildStep(c backend.CommitConfig) (image.ID, error)

CommitBuildStep is used by the builder to create an image for each step in the build.

This method is different from CreateImageFromContainer:

  • it doesn't attempt to validate container state
  • it doesn't send a commit action to metrics
  • it doesn't log a container commit event

This is a temporary shim. Should be removed when builder stops using commit.

func (*ImageService) CommitImage

func (i *ImageService) CommitImage(c backend.CommitConfig) (image.ID, error)

CommitImage creates a new image from a commit config

func (*ImageService) CountImages

func (i *ImageService) CountImages() int

CountImages returns the number of images stored by ImageService called from info.go

func (*ImageService) CreateImage

func (i *ImageService) CreateImage(config []byte, parent string) (builder.Image, error)

CreateImage creates a new image by adding a config and ID to the image store. This is similar to LoadImage() except that it receives JSON encoded bytes of an image instead of a tar archive.

func (*ImageService) CreateLayer

func (i *ImageService) CreateLayer(container *container.Container, initFunc layer.MountInit) (layer.RWLayer, error)

CreateLayer creates a filesystem layer for a container. called from create.go TODO: accept an opt struct instead of container?

func (*ImageService) DistributionServices

func (i *ImageService) DistributionServices() DistributionServices

DistributionServices return services controlling daemon image storage

func (*ImageService) ExportImage

func (i *ImageService) ExportImage(names []string, outStream io.Writer) error

ExportImage exports a list of images to the given output stream. The exported images are archived into a tar when written to the output stream. All images with the given tag and all versions containing the same tag are exported. names is the set of tags to export, and outStream is the writer which the images are written to.

func (*ImageService) GetContainerLayerSize

func (i *ImageService) GetContainerLayerSize(containerID string) (int64, int64)

GetContainerLayerSize returns the real size & virtual size of the container.

func (*ImageService) GetImage

func (i *ImageService) GetImage(refOrID string, platform *specs.Platform) (retImg *image.Image, retErr error)

GetImage returns an image corresponding to the image referred to by refOrID.

func (*ImageService) GetImageAndReleasableLayer

func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error)

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.

func (*ImageService) GetLayerByID

func (i *ImageService) GetLayerByID(cid string, os string) (layer.RWLayer, error)

GetLayerByID returns a layer by ID and operating system called from daemon.go Daemon.restore(), and Daemon.containerExport()

func (*ImageService) GetLayerMountID

func (i *ImageService) GetLayerMountID(cid string, os string) (string, error)

GetLayerMountID returns the mount ID for a layer called from daemon.go Daemon.Shutdown(), and Daemon.Cleanup() (cleanup is actually continerCleanup) TODO: needs to be refactored to Unmount (see callers), or removed and replaced with GetLayerByID

func (*ImageService) GetRepository

func (i *ImageService) GetRepository(ctx context.Context, ref reference.Named, authConfig *types.AuthConfig) (dist.Repository, bool, error)

GetRepository returns a repository from the registry.

func (*ImageService) GraphDriverForOS

func (i *ImageService) GraphDriverForOS(os string) string

GraphDriverForOS returns the name of the graph drvier moved from Daemon.GraphDriverName, used by: - newContainer - to report an error in Daemon.Mount(container)

func (*ImageService) ImageDelete

func (i *ImageService) ImageDelete(imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)

ImageDelete deletes the image referenced by the given imageRef from this daemon. The given imageRef can be an image ID, ID prefix, or a repository reference (with an optional tag or digest, defaulting to the tag name "latest"). There is differing behavior depending on whether the given imageRef is a repository reference or not.

If the given imageRef is a repository reference then that repository reference will be removed. However, if there exists any containers which were created using the same image reference then the repository reference cannot be removed unless either there are other repository references to the same image or force is true. Following removal of the repository reference, the referenced image itself will attempt to be deleted as described below but quietly, meaning any image delete conflicts will cause the image to not be deleted and the conflict will not be reported.

There may be conflicts preventing deletion of an image and these conflicts are divided into two categories grouped by their severity:

Hard Conflict:

  • a pull or build using the image.
  • any descendant image.
  • any running container using the image.

Soft Conflict:

  • any stopped container using the image.
  • any repository tag or digest references to the image.

The image cannot be removed if there are any hard conflicts and can be removed if there are soft conflicts only if force is true.

If prune is true, ancestor images will each attempt to be deleted quietly, meaning any delete conflicts will cause the image to not be deleted and the conflict will not be reported.

func (*ImageService) ImageHistory

func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem, error)

ImageHistory returns a slice of ImageHistory structures for the specified image name by walking the image lineage.

func (*ImageService) Images

func (i *ImageService) Images(imageFilters filters.Args, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error)

Images returns a filtered list of images. filterArgs is a JSON-encoded set of filter arguments which will be interpreted by api/types/filters. filter is a shell glob string applied to repository names. The argument named all controls whether all images in the graph are filtered, or just the heads.

func (*ImageService) ImagesPrune

func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)

ImagesPrune removes unused images

func (*ImageService) ImportImage

func (i *ImageService) ImportImage(src string, repository, os string, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error

ImportImage imports an image, getting the archived layer data either from inConfig (if src is "-"), or from a URI specified in src. Progress output is written to outStream. Repository and tag names can optionally be given in the repo and tag arguments, respectively.

func (*ImageService) LayerDiskUsage

func (i *ImageService) LayerDiskUsage(ctx context.Context) (int64, error)

LayerDiskUsage returns the number of bytes used by layer stores called from disk_usage.go

func (*ImageService) LayerStoreStatus

func (i *ImageService) LayerStoreStatus() map[string][][2]string

LayerStoreStatus returns the status for each layer store called from info.go

func (*ImageService) LoadImage

func (i *ImageService) LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error

LoadImage uploads a set of images into the repository. This is the complement of ImageExport. The input stream is an uncompressed tar ball containing images and metadata.

func (*ImageService) LogImageEvent

func (i *ImageService) LogImageEvent(imageID, refName, action string)

LogImageEvent generates an event related to an image with only the default attributes.

func (*ImageService) LogImageEventWithAttributes

func (i *ImageService) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string)

LogImageEventWithAttributes generates an event related to an image with specific given attributes.

func (*ImageService) LookupImage

func (i *ImageService) LookupImage(name string) (*types.ImageInspect, error)

LookupImage looks up an image by name and returns it as an ImageInspect structure.

func (*ImageService) MakeImageCache

func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache

MakeImageCache creates a stateful image cache.

func (*ImageService) Map

func (i *ImageService) Map() map[image.ID]*image.Image

Map returns a map of all images in the ImageStore

func (*ImageService) PullImage

func (i *ImageService) PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error

PullImage initiates a pull operation. image is the repository name to pull, and tag may be either empty, or indicate a specific tag to pull.

func (*ImageService) PushImage

func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error

PushImage initiates a push operation on the repository named localName.

func (*ImageService) ReleaseLayer

func (i *ImageService) ReleaseLayer(rwlayer layer.RWLayer, containerOS string) error

ReleaseLayer releases a layer allowing it to be removed called from delete.go Daemon.cleanupContainer(), and Daemon.containerExport()

func (*ImageService) SearchRegistryForImages

func (i *ImageService) SearchRegistryForImages(ctx context.Context, filtersArgs string, term string, limit int,
	authConfig *types.AuthConfig,
	headers map[string][]string) (*registrytypes.SearchResults, error)

SearchRegistryForImages queries the registry for images matching term. authConfig is used to login.

TODO: this could be implemented in a registry service instead of the image service.

func (*ImageService) SquashImage

func (i *ImageService) SquashImage(id, parent string) (string, error)

SquashImage creates a new image with the diff of the specified image and the specified parent. This new image contains only the layers from it's parent + 1 extra layer which contains the diff of all the layers in between. The existing image(s) is not destroyed. If no parent is specified, a new image with the diff of all the specified image's layers merged into a new layer that has no parents.

func (*ImageService) TagImage

func (i *ImageService) TagImage(imageName, repository, tag string) (string, error)

TagImage creates the tag specified by newTag, pointing to the image named imageName (alternatively, imageName can also be an image ID).

func (*ImageService) TagImageWithReference

func (i *ImageService) TagImageWithReference(imageID image.ID, newTag reference.Named) error

TagImageWithReference adds the given reference to the image ID provided.

func (*ImageService) UpdateConfig

func (i *ImageService) UpdateConfig(maxDownloads, maxUploads *int)

UpdateConfig values

called from reload.go

type ImageServiceConfig

type ImageServiceConfig struct {
	ContainerStore            containerStore
	DistributionMetadataStore metadata.Store
	EventsService             *daemonevents.Events
	ImageStore                image.Store
	LayerStores               map[string]layer.Store
	MaxConcurrentDownloads    int
	MaxConcurrentUploads      int
	MaxDownloadAttempts       int
	ReferenceStore            dockerreference.Store
	RegistryService           registry.Service
	TrustKey                  libtrust.PrivateKey
	ContentStore              content.Store
	Leases                    leases.Manager
	ContentNamespace          string
}

ImageServiceConfig is the configuration used to create a new ImageService

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL