containerd

package
v24.0.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImageService

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

ImageService implements daemon.ImageService

func NewService

func NewService(config ImageServiceConfig) *ImageService

NewService creates a new ImageService.

func (*ImageService) Changes

func (i *ImageService) Changes(ctx context.Context, container *container.Container) ([]archive.Change, error)

func (*ImageService) Children

func (i *ImageService) Children(ctx context.Context, id image.ID) ([]image.ID, error)

Children returns a slice of image ID which rootfs is a superset of the rootfs of the given image ID, excluding images with exactly the same rootfs. Called from list.go to filter containers.

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, cc 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() images.DistributionServices

DistributionServices return services controlling daemon image storage.

func (*ImageService) ExportImage

func (i *ImageService) ExportImage(ctx context.Context, 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.

TODO(thaJeztah): produce JSON stream progress response and image events; see https://github.com/moby/moby/issues/43910

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 imagetype.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 imagetype.GetImageOpts) (*ocispec.Descriptor, error)

func (*ImageService) GetLayerFolders

func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer) ([]string, error)

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.

TODO(thaJeztah): implement ImageDelete "force" options; see https://github.com/moby/moby/issues/43850 TODO(thaJeztah): implement ImageDelete "prune" options; see https://github.com/moby/moby/issues/43849 TODO(thaJeztah): image delete should send prometheus counters; see https://github.com/moby/moby/issues/45268

func (*ImageService) ImageHistory

func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*imagetype.HistoryResponseItem, error)

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

func (*ImageService) Images

Images returns a filtered list of images.

TODO(thaJeztah): sort the results by created (descending); see https://github.com/moby/moby/issues/43848 TODO(thaJeztah): implement opts.ContainerCount (used for docker system df); see https://github.com/moby/moby/issues/43853 TODO(thaJeztah): add labels to results; see https://github.com/moby/moby/issues/43852 TODO(thaJeztah): verify behavior of `RepoDigests` and `RepoTags` for images without (untagged) or multiple tags; see https://github.com/moby/moby/issues/43861 TODO(thaJeztah): verify "Size" vs "VirtualSize" in images; see https://github.com/moby/moby/issues/43862

func (*ImageService) ImagesPrune

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

ImagesPrune removes unused images

func (*ImageService) ImportImage

func (i *ImageService) ImportImage(ctx context.Context, ref 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. Layer archive is imported as-is if the compression is gzip or zstd. Uncompressed, xz and bzip2 archives are recompressed into gzip. The image is tagged with the given reference. If the platform is nil, the default host platform is used. The message is used as the 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, action string)

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

func (*ImageService) MakeImageCache

func (i *ImageService) MakeImageCache(ctx context.Context, cacheFrom []string) (builder.ImageCache, error)

MakeImageCache creates a stateful image cache.

func (*ImageService) Mount

func (i *ImageService) Mount(ctx context.Context, container *container.Container) error

Mount mounts the container filesystem in a temporary location, use defer imageService.Unmount to unmount the filesystem when calling this

func (*ImageService) PerformWithBaseFS

func (i *ImageService) PerformWithBaseFS(ctx context.Context, c *container.Container, fn func(root string) error) error

func (*ImageService) PrepareSnapshot

func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *v1.Platform) error

PrepareSnapshot prepares a snapshot from a parent image for a container

func (*ImageService) PullImage

func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, platform *specs.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 tagOrDigest may be either empty, or indicate a specific tag or digest to pull.

func (*ImageService) PushImage

func (i *ImageService) PushImage(ctx context.Context, targetRef reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error

PushImage initiates a push operation of the image pointed to by targetRef. Image manifest (or index) is pushed as is, which will probably fail if you don't have all content referenced by the index. Cross-repo mounts will be attempted for non-existing blobs.

It will also add distribution source labels to the pushed content pointing to the new target repository. This will allow subsequent pushes to perform cross-repo mounts of the shared content when pushing to a different repository on the same registry.

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(), and Daemon.containerExport()

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 its 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 default storage-driver (snapshotter) used by the ImageService.

func (*ImageService) TagImage

func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error

TagImage creates an image named as newTag and targeting the given descriptor id.

func (*ImageService) Unmount

func (i *ImageService) Unmount(ctx context.Context, container *container.Container) error

Unmount unmounts the container base filesystem

func (*ImageService) UpdateConfig

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

UpdateConfig values

called from reload.go

type ImageServiceConfig

type ImageServiceConfig struct {
	Client        *containerd.Client
	Containers    container.Store
	Snapshotter   string
	HostsProvider RegistryHostsProvider
	Registry      RegistryConfigProvider
	EventsService *daemonevents.Events
}

type RegistryConfigProvider

type RegistryConfigProvider interface {
	IsInsecureRegistry(host string) bool
}

type RegistryHostsProvider

type RegistryHostsProvider interface {
	RegistryHosts() docker.RegistryHosts
}

Jump to

Keyboard shortcuts

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