Documentation ¶
Index ¶
- func OnlyPlatformWithFallback(p ocispec.Platform) platforms.Matcher
- type DistributionServices
- type ErrImageDoesNotExist
- type ImageService
- func (i *ImageService) Changes(ctx context.Context, container *container.Container) ([]archive.Change, error)
- func (i *ImageService) Children(_ context.Context, id image.ID) ([]image.ID, error)
- func (i *ImageService) Cleanup() error
- func (i *ImageService) CommitBuildStep(ctx context.Context, c backend.CommitConfig) (image.ID, error)
- func (i *ImageService) CommitImage(ctx context.Context, c backend.CommitConfig) (image.ID, error)
- func (i *ImageService) CountImages() int
- func (i *ImageService) CreateImage(ctx context.Context, config []byte, parent string, _ digest.Digest) (builder.Image, error)
- func (i *ImageService) CreateLayer(container *container.Container, initFunc layer.MountInit) (layer.RWLayer, error)
- func (i *ImageService) DistributionServices() DistributionServices
- func (i *ImageService) ExportImage(ctx context.Context, names []string, outStream io.Writer) error
- func (i *ImageService) GetContainerLayerSize(ctx context.Context, containerID string) (int64, int64, error)
- func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*image.Image, error)
- func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error)
- func (i *ImageService) GetImageManifest(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*ocispec.Descriptor, error)
- func (i *ImageService) GetLayerByID(cid string) (layer.RWLayer, error)
- func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer) ([]string, error)
- func (i *ImageService) GetLayerMountID(cid string) (string, error)
- func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
- func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*image.HistoryResponseItem, error)
- func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
- func (i *ImageService) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)
- func (i *ImageService) ImportImage(ctx context.Context, newRef reference.Named, platform *ocispec.Platform, ...) (image.ID, error)
- func (i *ImageService) LayerDiskUsage(ctx context.Context) (int64, error)
- func (i *ImageService) LayerStoreStatus() [][2]string
- func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error
- func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action)
- func (i *ImageService) MakeImageCache(ctx context.Context, sourceRefs []string) (builder.ImageCache, error)
- func (i *ImageService) Mount(ctx context.Context, container *container.Container) error
- func (i *ImageService) PerformWithBaseFS(ctx context.Context, c *container.Container, fn func(root string) error) error
- func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, image string, platform *ocispec.Platform) error
- func (i *ImageService) PullImage(ctx context.Context, image, tag string, platform *ocispec.Platform, ...) error
- func (i *ImageService) PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, ...) error
- func (i *ImageService) ReleaseLayer(rwlayer layer.RWLayer) error
- func (i *ImageService) SquashImage(id, parent string) (string, error)
- func (i *ImageService) StorageDriver() string
- func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error
- func (i *ImageService) Unmount(ctx context.Context, container *container.Container) error
- func (i *ImageService) UpdateConfig(maxDownloads, maxUploads int)
- type ImageServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnlyPlatformWithFallback ¶
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 *xfer.LayerDownloadManager V2MetadataService metadata.V2MetadataService LayerStore layer.Store ImageStore image.Store ReferenceStore dockerreference.Store }
DistributionServices provides daemon image storage services
type ErrImageDoesNotExist ¶
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 ¶
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() error
Cleanup resources before the process is shutdown. called from daemon.go Daemon.Shutdown()
func (*ImageService) CommitBuildStep ¶
func (i *ImageService) CommitBuildStep(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, config []byte, parent string, _ digest.Digest) (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 ¶
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(ctx context.Context, containerID string) (int64, int64, error)
GetContainerLayerSize returns the real size & virtual size of the container.
func (*ImageService) GetImage ¶
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*image.Image, 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) GetImageManifest ¶
func (i *ImageService) GetImageManifest(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*ocispec.Descriptor, error)
func (*ImageService) GetLayerByID ¶
func (i *ImageService) GetLayerByID(cid string) (layer.RWLayer, error)
GetLayerByID returns a layer by ID called from daemon.go Daemon.restore().
func (*ImageService) GetLayerFolders ¶
GetLayerFolders returns the layer folders from an image RootFS
func (*ImageService) GetLayerMountID ¶
func (i *ImageService) GetLayerMountID(cid 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) ImageDelete ¶
func (i *ImageService) ImageDelete(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
Images returns a filtered list of images.
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(ctx context.Context, newRef reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error)
ImportImage imports an image, getting the archived layer data from layerReader. Uncompressed layer archive is passed to the layerStore and handled by the underlying graph driver. Image is tagged with the given reference. If the platform is nil, the default host platform is used. Message is used as the image's history comment. Image configuration is derived from the dockerfile instructions in changes.
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() [][2]string
LayerStoreStatus returns the status for each layer store called from info.go
func (*ImageService) LoadImage ¶
func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error
LoadImage uploads a set of images into the repository. This is the complement of ExportImage. The input stream is an uncompressed tar ball containing images and metadata.
func (*ImageService) LogImageEvent ¶
func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action)
LogImageEvent generates an event related to an image with only the default attributes.
func (*ImageService) MakeImageCache ¶
func (i *ImageService) MakeImageCache(ctx context.Context, sourceRefs []string) (builder.ImageCache, error)
MakeImageCache creates a stateful image cache.
func (*ImageService) Mount ¶
Mount sets container.BaseFS (is it not set coming in? why is it unset?)
func (*ImageService) PerformWithBaseFS ¶
func (*ImageService) PrepareSnapshot ¶
func (*ImageService) PullImage ¶
func (i *ImageService) PullImage(ctx context.Context, image, tag string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.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, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.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) error
ReleaseLayer releases a layer allowing it to be removed called from delete.go Daemon.cleanupContainer().
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) StorageDriver ¶
func (i *ImageService) StorageDriver() string
StorageDriver returns the name of the storage driver used by the ImageService.
func (*ImageService) TagImage ¶
func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error
TagImage 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 LayerStore layer.Store MaxConcurrentDownloads int MaxConcurrentUploads int MaxDownloadAttempts int ReferenceStore dockerreference.Store RegistryService distribution.RegistryResolver ContentStore content.Store Leases leases.Manager ContentNamespace string }
ImageServiceConfig is the configuration used to create a new ImageService