docker

package
v0.0.0-...-03ac62e Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Zlib Imports: 29 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerCreate

func ContainerCreate(
	config *container.Config,
	hostConfig *container.HostConfig,
	networkingConfig *network.NetworkingConfig,
	platform *specs.Platform,
	containerName string,
) (container.CreateResponse, error)

func ContainerDelete

func ContainerDelete(name string, opts container.RemoveOptions) error

func ContainerKill

func ContainerKill(name string) error

func ContainerRestart

func ContainerRestart(name string) error

func ContainerStart

func ContainerStart(name string, opts container.StartOptions) error

func ContainerStop

func ContainerStop(name string) error

func ContainerWait

func ContainerWait(name string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)

func CopyGitStackToHost

func CopyGitStackToHost(src, dst string, stackID int, stackName string) error

CopyGitStackToHost copies src folder to the dst folder on the host

func CopyToContainer

func CopyToContainer(containerID, dstPath, srcPath string) error

func CreateSnapshot

func CreateSnapshot(edgeKey string) (*portainer.DockerSnapshot, error)

func GetContainerLogs

func GetContainerLogs(containerName, tail, since, until string) ([]byte, []byte, error)

func GetContainersWithLabel

func GetContainersWithLabel(value string) (r []types.Container, err error)

func GetLiveContainerLogs

func GetLiveContainerLogs(containerName, since, until, tail string) (*io.PipeReader, *io.PipeReader, error)

func GetVolumeMountpoint

func GetVolumeMountpoint(volumeID string) (string, error)

GetVolumeMountpoint returns the Mountpoint of the named volume as reported by the Docker daemon (e.g. /mnt/docker-data/volumes/test_volume/_data).

func ImageDelete

func ImageDelete(name string, opts image.RemoveOptions) (r []image.DeleteResponse, err error)

func ImagePull

func ImagePull(refStr string, options image.PullOptions) (io.ReadCloser, error)

func NewClient

func NewClient() (*client.Client, error)

func NewClientWithoutTimeout

func NewClientWithoutTimeout() (*client.Client, error)

func RemoveGitStackFromHost

func RemoveGitStackFromHost(src, dst string, stackID int, stackName string) error

RemoveGitStackFromHost removes the copy of src folder on the host

func VolumeDelete

func VolumeDelete(name string, force bool) error

Types

type CleanupClient

type CleanupClient interface {
	// ContainerList lists containers (used to determine which images are in use).
	ContainerList(ctx context.Context, opts container.ListOptions) ([]container.Summary, error)
	// ImageList lists images available on the daemon.
	ImageList(ctx context.Context, opts image.ListOptions) ([]image.Summary, error)
	// ImageRemove removes an image by ID.
	ImageRemove(ctx context.Context, imageID string, opts image.RemoveOptions) ([]image.DeleteResponse, error)
	// DiskUsage returns Docker's own accounting of disk space used by images,
	// containers, volumes, and build cache (equivalent to "docker system df").
	DiskUsage(ctx context.Context, options dockertypes.DiskUsageOptions) (dockertypes.DiskUsage, error)
	// BuildCachePrune removes all Docker build cache entries.
	BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error)
	Close() error
}

CleanupClient is the subset of the Docker client API used for image garbage collection and storage usage queries. *client.Client already satisfies this interface, so production code continues using the existing NewClient() path while tests can inject a mock.

func NewCleanupClient

func NewCleanupClient() (CleanupClient, error)

NewCleanupClient creates a new CleanupClient backed by the production Docker client.

type CleanupClientFactory

type CleanupClientFactory func() (CleanupClient, error)

CleanupClientFactory is a function that creates a CleanupClient. Tests can provide a factory that returns a mock CleanupClient.

type InfoService

type InfoService struct{}

DockerInfoService is a service used to retrieve information from a Docker environment using the Docker library.

func NewInfoService

func NewInfoService() InfoService

NewInfoService returns a pointer to an instance of DockerInfoService

func (InfoService) GetContainerIpFromDockerEngine

func (service InfoService) GetContainerIpFromDockerEngine(containerName string, ignoreNonSwarmNetworks bool) (string, error)

GetContainerIpFromDockerEngine is used to retrieve the IP address of the container through Docker. It will inspect the container to retrieve the networks associated to the container and returns the IP associated to the first network found that is not an ingress network. If the ignoreNonSwarmNetworks parameter is specified, it will also ignore non Swarm scoped networks.

func (InfoService) GetRuntimeConfigurationFromDockerEngine

func (service InfoService) GetRuntimeConfigurationFromDockerEngine() (*agent.RuntimeConfig, error)

GetRuntimeConfigurationFromDockerEngine retrieves information from a Docker environment and returns a map of labels.

func (InfoService) GetServiceNameFromDockerEngine

func (service InfoService) GetServiceNameFromDockerEngine(containerName string) (string, error)

GetServiceNameFromDockerEngine is used to return the name of the Swarm service the agent is part of. The service name is retrieved through container labels.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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