{"modulePath":"github.com/fierlion/amazon-ecs-agent","version":"v1.23.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package dockerapi\n\n## Constants\n\n```go\nconst (\n\n\t// CreateContainerTimeout is the timeout for the CreateContainer API.\n\tCreateContainerTimeout = 4 * time.Minute\n\t// StopContainerTimeout is the timeout for the StopContainer API.\n\tStopContainerTimeout = 30 * time.Second\n\t// RemoveContainerTimeout is the timeout for the RemoveContainer API.\n\tRemoveContainerTimeout = 5 * time.Minute\n\t// InspectContainerTimeout is the timeout for the InspectContainer API.\n\tInspectContainerTimeout = 30 * time.Second\n\t// RemoveImageTimeout is the timeout for the RemoveImage API.\n\tRemoveImageTimeout = 3 * time.Minute\n\t// ListPluginsTimeout is the timout for ListPlugins API.\n\tListPluginsTimeout = 1 * time.Minute\n\t// CreateVolumeTimeout is the timout for CreateVolume API.\n\tCreateVolumeTimeout = 5 * time.Minute\n\t// InspectVolumeTimeout is the timout for InspectVolume API.\n\tInspectVolumeTimeout = 5 * time.Minute\n\t// RemoveVolumeTimeout is the timout for RemoveVolume API.\n\tRemoveVolumeTimeout = 5 * time.Minute\n\n\t// StatsInactivityTimeout controls the amount of time we hold open a\n\t// connection to the Docker daemon waiting for stats data\n\tStatsInactivityTimeout = 5 * time.Second\n)\n```\nTimelimits for docker operations enforced above docker TODO: Make these limits configurable.\n\n```go\nconst (\n\t// DockerTimeoutErrorName is the name of docker timeout error.\n\tDockerTimeoutErrorName = \"DockerTimeoutError\"\n\t// CannotInspectContainerErrorName is the name of container inspect error.\n\tCannotInspectContainerErrorName = \"CannotInspectContainerError\"\n\t// CannotDescribeContainerErrorName is the name of describe container error.\n\tCannotDescribeContainerErrorName = \"CannotDescribeContainerError\"\n)\n```\n\n```go\nconst (\n\n\t// VolumeDriverType is one of the plugin capabilities see https://docs.docker.com/engine/reference/commandline/plugin_ls/#filtering\n\tVolumeDriverType = \"volumedriver\"\n)\n```\n\n## Functions\n\n```go\nfunc DockerStateToState(state docker.State) apicontainerstatus.ContainerStatus\n```\nDockerStateToState converts the container status from docker to status recognized by the agent Ref: [https://github.com/fsouza/go-dockerclient/blob/fd53184a1439b6d7b82ca54c1cd9adac9a5278f2/container.go#L133](https://github.com/fsouza/go-dockerclient/blob/fd53184a1439b6d7b82ca54c1cd9adac9a5278f2/container.go#L133)\n\n## Types\n\n```go\ntype CannotCreateContainerError struct {\n\tFromError error\n}\n```\nCannotCreateContainerError indicates any error when trying to create a container\n\n```go\nfunc (err CannotCreateContainerError) Error() string\n```\n\n```go\nfunc (err CannotCreateContainerError) ErrorName() string\n```\nErrorName returns name of the CannotCreateContainerError.\n\n```go\ntype CannotCreateVolumeError struct {\n\t// contains filtered or unexported fields\n}\n```\nCannotCreateVolumeError indicates any error when trying to create a volume\n\n```go\nfunc (err CannotCreateVolumeError) Error() string\n```\n\n```go\nfunc (err CannotCreateVolumeError) ErrorName() string\n```\n\n```go\ntype CannotDescribeContainerError struct {\n\tFromError error\n}\n```\nCannotDescribeContainerError indicates any error when trying to describe a container\n\n```go\nfunc (err CannotDescribeContainerError) Error() string\n```\n\n```go\nfunc (err CannotDescribeContainerError) ErrorName() string\n```\nErrorName returns name of the CannotDescribeContainerError\n\n```go\ntype CannotGetDockerClientError struct {\n\t// contains filtered or unexported fields\n}\n```\nCannotGetDockerClientError is a type for failing to get a specific Docker client\n\n```go\nfunc (c CannotGetDockerClientError) Error() string\n```\n\n```go\nfunc (CannotGetDockerClientError) ErrorName() string\n```\nErrorName returns the name of the CannotGetDockerClientError.\n\n```go\ntype CannotInspectContainerError struct {\n\tFromError error\n}\n```\nCannotInspectContainerError indicates any error when trying to inspect a container\n\n```go\nfunc (err CannotInspectContainerError) Error() string\n```\n\n```go\nfunc (err CannotInspectContainerError) ErrorName() string\n```\nErrorName returns name of the CannotInspectContainerError\n\n```go\ntype CannotInspectVolumeError struct {\n\t// contains filtered or unexported fields\n}\n```\nCannotInspectVolumeError indicates any error when trying to inspect a volume\n\n```go\nfunc (err CannotInspectVolumeError) Error() string\n```\n\n```go\nfunc (err CannotInspectVolumeError) ErrorName() string\n```\n\n```go\ntype CannotListContainersError struct {\n\tFromError error\n}\n```\nCannotListContainersError indicates any error when trying to list containers\n\n```go\nfunc (err CannotListContainersError) Error() string\n```\n\n```go\nfunc (err CannotListContainersError) ErrorName() string\n```\nErrorName returns name of the CannotListContainersError\n\n```go\ntype CannotListPluginsError struct {\n\t// contains filtered or unexported fields\n}\n```\nCannotListPluginsError indicates any error when trying to list docker plugins\n\n```go\nfunc (err CannotListPluginsError) Error() string\n```\n\n```go\nfunc (err CannotListPluginsError) ErrorName() string\n```\n\n```go\ntype CannotPullContainerAuthError struct {\n\tFromError error\n}\n```\nCannotPullContainerAuthError indicates any error when trying to pull a container image\n\n```go\nfunc (err CannotPullContainerAuthError) Error() string\n```\n\n```go\nfunc (err CannotPullContainerAuthError) ErrorName() string\n```\nErrorName returns name of the CannotPullContainerAuthError.\n\n```go\nfunc (err CannotPullContainerAuthError) Retry() bool\n```\nRetry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry\\* functions\n\n```go\ntype CannotPullContainerError struct {\n\tFromError error\n}\n```\nCannotPullContainerError indicates any error when trying to pull a container image\n\n```go\nfunc (err CannotPullContainerError) Error() string\n```\n\n```go\nfunc (err CannotPullContainerError) ErrorName() string\n```\nErrorName returns name of the CannotPullContainerError.\n\n```go\ntype CannotPullECRContainerError struct {\n\tFromError error\n}\n```\nCannotPullECRContainerError indicates any error when trying to pull a container image from ECR\n\n```go\nfunc (err CannotPullECRContainerError) Error() string\n```\n\n```go\nfunc (err CannotPullECRContainerError) ErrorName() string\n```\nErrorName returns name of the CannotPullECRContainerError.\n\n```go\nfunc (err CannotPullECRContainerError) Retry() bool\n```\nRetry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry\\* functions\n\n```go\ntype CannotRemoveContainerError struct {\n\tFromError error\n}\n```\nCannotRemoveContainerError indicates any error when trying to remove a container\n\n```go\nfunc (err CannotRemoveContainerError) Error() string\n```\n\n```go\nfunc (err CannotRemoveContainerError) ErrorName() string\n```\nErrorName returns name of the CannotRemoveContainerError\n\n```go\ntype CannotRemoveVolumeError struct {\n\t// contains filtered or unexported fields\n}\n```\nCannotRemoveVolumeError indicates any error when trying to inspect a volume\n\n```go\nfunc (err CannotRemoveVolumeError) Error() string\n```\n\n```go\nfunc (err CannotRemoveVolumeError) ErrorName() string\n```\n\n```go\ntype CannotStartContainerError struct {\n\tFromError error\n}\n```\nCannotStartContainerError indicates any error when trying to start a container\n\n```go\nfunc (err CannotStartContainerError) Error() string\n```\n\n```go\nfunc (err CannotStartContainerError) ErrorName() string\n```\nErrorName returns name of the CannotStartContainerError\n\n```go\ntype CannotStopContainerError struct {\n\tFromError error\n}\n```\nCannotStopContainerError indicates any error when trying to stop a container\n\n```go\nfunc (err CannotStopContainerError) Error() string\n```\n\n```go\nfunc (err CannotStopContainerError) ErrorName() string\n```\nErrorName returns name of the CannotStopContainerError.\n\n```go\nfunc (err CannotStopContainerError) IsRetriableError() bool\n```\nIsRetriableError returns a boolean indicating whether the call that generated the error can be retried. When stopping a container, most errors that we can get should be considered retriable. However, in the case where the container is already stopped or doesn't exist at all, there's no sense in retrying.\n\n```go\ntype ContainerNotFound struct {\n\t// TaskArn is the ARN of the task the container belongs to\n\tTaskArn string\n\t// ContainerName is the name of the container that's missing\n\tContainerName string\n}\n```\nContainerNotFound is a type for a missing container\n\n```go\nfunc (cnferror ContainerNotFound) Error() string\n```\nError returns an error string for the ContainerNotFound error\n\n```go\ntype DockerClient interface {\n\t// SupportedVersions returns a slice of the supported docker versions (or at least supposedly supported).\n\tSupportedVersions() []dockerclient.DockerVersion\n\n\t// KnownVersions returns a slice of the Docker API versions known to the Docker daemon.\n\tKnownVersions() []dockerclient.DockerVersion\n\n\t// WithVersion returns a new DockerClient for which all operations will use the given remote api version.\n\t// A default version will be used for a client not produced via this method.\n\tWithVersion(dockerclient.DockerVersion) DockerClient\n\n\t// ContainerEvents returns a channel of DockerContainerChangeEvents. Events are placed into the channel and should\n\t// be processed by the listener.\n\tContainerEvents(ctx context.Context) (\u003c-chan DockerContainerChangeEvent, error)\n\n\t// PullImage pulls an image. authData should contain authentication data provided by the ECS backend.\n\tPullImage(image string, authData *apicontainer.RegistryAuthenticationData) DockerContainerMetadata\n\n\t// CreateContainer creates a container with the provided docker.Config, docker.HostConfig, and name. A timeout value\n\t// and a context should be provided for the request.\n\tCreateContainer(context.Context, *docker.Config, *docker.HostConfig, string, time.Duration) DockerContainerMetadata\n\n\t// StartContainer starts the container identified by the name provided. A timeout value and a context should be\n\t// provided for the request.\n\tStartContainer(context.Context, string, time.Duration) DockerContainerMetadata\n\n\t// StopContainer stops the container identified by the name provided. A timeout value and a context should be provided\n\t// for the request.\n\tStopContainer(context.Context, string, time.Duration) DockerContainerMetadata\n\n\t// DescribeContainer returns status information about the specified container. A context should be provided\n\t// for the request\n\tDescribeContainer(context.Context, string) (apicontainerstatus.ContainerStatus, DockerContainerMetadata)\n\n\t// RemoveContainer removes a container (typically the rootfs, logs, and associated metadata) identified by the name.\n\t// A timeout value and a context should be provided for the request.\n\tRemoveContainer(context.Context, string, time.Duration) error\n\n\t// InspectContainer returns information about the specified container. A timeout value and a context should be\n\t// provided for the request.\n\tInspectContainer(context.Context, string, time.Duration) (*docker.Container, error)\n\n\t// ListContainers returns the set of containers known to the Docker daemon. A timeout value and a context\n\t// should be provided for the request.\n\tListContainers(context.Context, bool, time.Duration) ListContainersResponse\n\n\t// CreateVolume creates a docker volume. A timeout value should be provided for the request\n\tCreateVolume(context.Context, string, string, map[string]string, map[string]string, time.Duration) VolumeResponse\n\n\t// InspectVolume returns a volume by its name. A timeout value should be provided for the request\n\tInspectVolume(context.Context, string, time.Duration) VolumeResponse\n\n\t// RemoveVolume removes a volume by its name. A timeout value should be provided for the request\n\tRemoveVolume(context.Context, string, time.Duration) error\n\n\t// ListPluginsWithFilters returns the set of docker plugins installed on the host, filtered by options provided.\n\t// A timeout value should be provided for the request.\n\tListPluginsWithFilters(context.Context, bool, []string, time.Duration) ([]string, error)\n\n\t// ListPlugins returns the set of docker plugins installed on the host. A timeout value should be provided for\n\t// the request.\n\tListPlugins(context.Context, time.Duration) ListPluginsResponse\n\n\t// Stats returns a channel of stat data for the specified container. A context should be provided so the request can\n\t// be canceled.\n\tStats(string, context.Context) (\u003c-chan *docker.Stats, error)\n\n\t// Version returns the version of the Docker daemon.\n\tVersion(context.Context, time.Duration) (string, error)\n\n\t// APIVersion returns the api version of the client\n\tAPIVersion() (dockerclient.DockerVersion, error)\n\n\t// InspectImage returns information about the specified image.\n\tInspectImage(string) (*docker.Image, error)\n\n\t// RemoveImage removes the metadata associated with an image and may remove the underlying layer data. A timeout\n\t// value and a context should be provided for the request.\n\tRemoveImage(context.Context, string, time.Duration) error\n\t// LoadImage loads an image from an input stream. A timeout value and a context should be provided for the request.\n\tLoadImage(context.Context, io.Reader, time.Duration) error\n}\n```\nDockerClient interface to make testing it easier\n\n```go\nfunc NewDockerGoClient(clientFactory clientfactory.Factory, cfg *config.Config) (DockerClient, error)\n```\nNewDockerGoClient creates a new DockerGoClient\n\n```go\ntype DockerContainerChangeEvent struct {\n\t// Status represents the container's status in the event\n\tStatus apicontainerstatus.ContainerStatus\n\t// DockerContainerMetadata is the metadata of the container in the event\n\tDockerContainerMetadata\n\t// Type is the event type received from docker events\n\tType apicontainer.DockerEventType\n}\n```\nDockerContainerChangeEvent is a type for container change events\n\n```go\nfunc (event *DockerContainerChangeEvent) String() string\n```\nString returns a human readable string of the container change event\n\n```go\ntype DockerContainerMetadata struct {\n\t// DockerID is the contianer's id generated by Docker\n\tDockerID string\n\t// ExitCode contains container's exit code if it has stopped\n\tExitCode *int\n\t// PortBindings is the list of port binding information of the container\n\tPortBindings []apicontainer.PortBinding\n\t// Error wraps various container transition errors and is set if engine\n\t// is unable to perform any of the required container transitions\n\tError apierrors.NamedError\n\t// Volumes contains volume informaton for the container\n\tVolumes []docker.Mount\n\t// Labels contains labels set for the container\n\tLabels map[string]string\n\t// CreatedAt is the timestamp of container creation\n\tCreatedAt time.Time\n\t// StartedAt is the timestamp of container start\n\tStartedAt time.Time\n\t// FinishedAt is the timestamp of container stop\n\tFinishedAt time.Time\n\t// Health contains the result of a container health check\n\tHealth apicontainer.HealthStatus\n}\n```\nDockerContainerMetadata is a type for metadata about Docker containers\n\n```go\nfunc MetadataFromContainer(dockerContainer *docker.Container) DockerContainerMetadata\n```\nMetadataFromContainer translates dockerContainer into DockerContainerMetadata\n\n```go\ntype DockerStateError struct {\n\t// contains filtered or unexported fields\n}\n```\nDockerStateError is a wrapper around the error docker puts in the '.State.Error' field of its inspect output.\n\n```go\nfunc NewDockerStateError(err string) DockerStateError\n```\nNewDockerStateError creates a DockerStateError\n\n```go\nfunc (err DockerStateError) Error() string\n```\n\n```go\nfunc (err DockerStateError) ErrorName() string\n```\nErrorName returns the name of the DockerStateError.\n\n```go\ntype DockerTimeoutError struct {\n\t// Duration is the timeout period.\n\tDuration time.Duration\n\t// Transition is the description of operation that timed out.\n\tTransition string\n}\n```\nDockerTimeoutError is an error type for describing timeouts\n\n```go\nfunc (err *DockerTimeoutError) Error() string\n```\n\n```go\nfunc (err *DockerTimeoutError) ErrorName() string\n```\nErrorName returns the name of the error\n\n```go\ntype InfiniteBuffer struct {\n\t// contains filtered or unexported fields\n}\n```\nInfiniteBuffer defines an unlimited buffer, where it reads from input channel and write to output channel.\n\n```go\nfunc NewInfiniteBuffer() *InfiniteBuffer\n```\nNewInfiniteBuffer returns an InfiniteBuffer object\n\n```go\nfunc (buffer *InfiniteBuffer) Consume(in chan\u003c- *docker.APIEvents)\n```\nConsume reads the buffer and write to a listener channel\n\n```go\nfunc (buffer *InfiniteBuffer) CopyEvents(event *docker.APIEvents)\n```\nCopyEvents copies the event into the buffer\n\n```go\nfunc (buffer *InfiniteBuffer) StartListening(events chan *docker.APIEvents)\n```\nStartListening starts reading from the input channel and writes to the buffer TODO: wire in ctx to stop listening\n\n```go\ntype ListContainersResponse struct {\n\t// DockerIDs is the list of container IDs from the ListContainers call\n\tDockerIDs []string\n\t// Error contains any error returned when listing containers\n\tError error\n}\n```\nListContainersResponse encapsulates the response from the docker client for the ListContainers call.\n\n```go\ntype ListPluginsResponse struct {\n\tPlugins []docker.PluginDetail\n\tError   error\n}\n```\nListPluginsResponse is a wrapper for ListPlugins api\n\n```go\ntype OutOfMemoryError struct{}\n```\nOutOfMemoryError is a type for errors caused by running out of memory\n\n```go\nfunc (err OutOfMemoryError) Error() string\n```\n\n```go\nfunc (err OutOfMemoryError) ErrorName() string\n```\nErrorName returns the name of the error\n\n```go\ntype VolumeResponse struct {\n\tDockerVolume *docker.Volume\n\tError        error\n}\n```\nVolumeResponse wrapper for CreateVolume and InspectVolume\n\n","path":"github.com/fierlion/amazon-ecs-agent/agent/dockerclient/dockerapi","name":"dockerapi","synopsis":"","isRedistributable":true}
