Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WaitConditionNotRunning = container.WaitConditionNotRunning
	WaitConditionNextExit   = container.WaitConditionNextExit
	WaitConditionRemoved    = container.WaitConditionRemoved
)

Variables

This section is empty.

Functions

func IsErrCanceled added in v0.5.0

func IsErrCanceled(err error) bool

IsErrCanceled reports whether err is from a canceled context. It unwraps wrapped errors.

func IsErrConflict added in v0.5.0

func IsErrConflict(err error) bool

IsErrConflict reports whether err is a Docker Engine conflict (HTTP 409), such as a name already in use or a container that is still running.

func IsErrDataLoss added in v0.5.0

func IsErrDataLoss(err error) bool

IsErrDataLoss reports whether err is a Docker Engine data-loss error.

func IsErrDeadlineExceeded added in v0.5.0

func IsErrDeadlineExceeded(err error) bool

IsErrDeadlineExceeded reports whether err is from a context deadline. It unwraps wrapped errors.

func IsErrInternal added in v0.5.0

func IsErrInternal(err error) bool

IsErrInternal reports whether err is a Docker Engine internal error (HTTP 500).

func IsErrInvalidArgument added in v0.5.0

func IsErrInvalidArgument(err error) bool

IsErrInvalidArgument reports whether err is a Docker Engine invalid-argument error (HTTP 400).

func IsErrNotFound

func IsErrNotFound(err error) bool

IsErrNotFound reports whether err is a Docker Engine "not found" error (container, image, network, volume, and similar). It unwraps wrapped errors.

func IsErrNotImplemented added in v0.5.0

func IsErrNotImplemented(err error) bool

IsErrNotImplemented reports whether err is a Docker Engine not-implemented error (HTTP 501).

func IsErrNotModified added in v0.5.0

func IsErrNotModified(err error) bool

IsErrNotModified reports whether err is a Docker Engine not-modified error (HTTP 304).

func IsErrPermissionDenied added in v0.5.0

func IsErrPermissionDenied(err error) bool

IsErrPermissionDenied reports whether err is a Docker Engine forbidden error (HTTP 403).

func IsErrUnauthorized added in v0.5.0

func IsErrUnauthorized(err error) bool

IsErrUnauthorized reports whether err is a Docker Engine authentication error (HTTP 401), including registry login failures.

func IsErrUnavailable added in v0.5.0

func IsErrUnavailable(err error) bool

IsErrUnavailable reports whether err is a Docker Engine unavailable error (HTTP 503), such as a daemon that cannot be reached.

func IsErrUnknown added in v0.5.0

func IsErrUnknown(err error) bool

IsErrUnknown reports whether err is an unclassified Docker Engine error.

Types

type BuildCachePrune added in v0.5.0

type BuildCachePrune sdk.BuildCachePruneOptions

BuildCachePrune is sdk.BuildCachePruneOptions.

type CheckpointCreate

type CheckpointCreate sdk.CheckpointCreateOptions

CheckpointCreate is sdk.CheckpointCreateOptions.

type CheckpointDelete

type CheckpointDelete sdk.CheckpointRemoveOptions

CheckpointDelete is sdk.CheckpointRemoveOptions.

type CheckpointList

type CheckpointList sdk.CheckpointListOptions

CheckpointList is sdk.CheckpointListOptions.

type Client

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

Client is a wrapper around the Docker Engine API client.

func NewClient

func NewClient(setters ...SetClientOption) (*Client, error)

NewClient initializes a client. Nil options are skipped.

func (*Client) BuildCachePrune added in v0.5.0

func (c *Client) BuildCachePrune(ctx context.Context, opt *BuildCachePrune) (*response.BuildCachePrune, error)

BuildCachePrune deletes unused build-cache records.

func (*Client) BuildCancel added in v0.5.0

func (c *Client) BuildCancel(ctx context.Context, id string) error

BuildCancel asks the daemon to cancel the build identified by id.

func (*Client) ClientVersion added in v0.5.0

func (c *Client) ClientVersion() string

ClientVersion returns the API version this client sends.

func (*Client) Close added in v0.5.0

func (c *Client) Close() error

Close closes idle connections used by the client.

func (*Client) ConfigCreate added in v0.5.0

func (c *Client) ConfigCreate(ctx context.Context, opt *ConfigCreate) (string, error)

ConfigCreate creates a swarm config and returns its ID.

func (*Client) ConfigInspect added in v0.5.0

func (c *Client) ConfigInspect(ctx context.Context, id string) (*response.SwarmConfig, error)

ConfigInspect returns one swarm config. Raw is the daemon's JSON body.

func (*Client) ConfigList added in v0.5.0

func (c *Client) ConfigList(ctx context.Context, opt *ConfigList) ([]response.SwarmConfig, error)

ConfigList returns swarm configs.

func (*Client) ConfigRemove added in v0.5.0

func (c *Client) ConfigRemove(ctx context.Context, id string) error

ConfigRemove removes a swarm config.

func (*Client) ConfigUpdate added in v0.5.0

func (c *Client) ConfigUpdate(ctx context.Context, id string, opt *ConfigUpdate) error

ConfigUpdate updates a swarm config.

func (*Client) ContainerAttach

func (c *Client) ContainerAttach(ctx context.Context, id string, opt *Attach) (*response.ContainerHijackedResponse, error)

ContainerAttach attaches a connection to a container in the server. It returns a hijacked connection and a reader to get output. It's up to the caller to close the hijacked connection.

The stream format on the response will be in one of two formats:

If the container is using a TTY, there is only a single stream (stdout), and data is copied directly from the container output stream, no extra multiplexing or headers.

If the container is *not* using a TTY, streams for stdout and stderr are multiplexed. The format of the multiplexed stream is as follows:

[8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}

STREAM_TYPE can be 1 for stdout and 2 for stderr

SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian. This is the size of OUTPUT.

You can use github.com/moby/moby/api/pkg/stdcopy.StdCopy to demultiplex this stream.

func (*Client) ContainerCheckpointCreate

func (c *Client) ContainerCheckpointCreate(ctx context.Context, id string, opt *CheckpointCreate) error

ContainerCheckpointCreate creates a checkpoint of a running container.

func (*Client) ContainerCheckpointDelete

func (c *Client) ContainerCheckpointDelete(ctx context.Context, id string, opt *CheckpointDelete) error

ContainerCheckpointDelete deletes the checkpoint with the given name from the given container

func (*Client) ContainerCheckpointList

func (c *Client) ContainerCheckpointList(ctx context.Context, id string, opt *CheckpointList) ([]response.ContainerCheckpointSummary, error)

ContainerCheckpointList returns the checkpoints of the given container in the docker host

func (*Client) ContainerCommit

func (c *Client) ContainerCommit(ctx context.Context, id string, opt *Commit) (*response.ContainerCommitResponse, error)

ContainerCommit applies changes to a container and creates a new tagged image.

func (*Client) ContainerCopyFromContainer

func (c *Client) ContainerCopyFromContainer(ctx context.Context, id string, srcPath string) (io.ReadCloser, *response.ContainerPathStat, error)

ContainerCopyFromContainer gets the content from the container and returns it as a Reader for a TAR archive to manipulate it in the host. It's up to the caller to close the reader.

func (*Client) ContainerCopyToContainer

func (c *Client) ContainerCopyToContainer(ctx context.Context, id string, dstPath string, opt *CopyTo) error

ContainerCopyToContainer copies content into the container filesystem. Note that content must be a Reader for a TAR archive

func (*Client) ContainerCreate

func (c *Client) ContainerCreate(ctx context.Context, created *kit.Container) (*response.ContainerCreate, error)

ContainerCreate creates a new container based on the given configuration. It can be associated with a name, but it's not mandatory.

func (*Client) ContainerDiff

func (c *Client) ContainerDiff(ctx context.Context, id string) ([]response.ContainerFilesystemChange, error)

ContainerDiff returns the changes on a container's filesystem.

func (*Client) ContainerExecAttach

func (c *Client) ContainerExecAttach(ctx context.Context, execID string, opt *ExecAttach) (*response.ContainerHijackedResponse, error)

ContainerExecAttach attaches a connection to an exec process in the server. It returns a hijacked connection and a reader to get output. It's up to the caller to close the hijacked connection.

func (*Client) ContainerExecAttachTerminal

func (c *Client) ContainerExecAttachTerminal(ctx context.Context, execID string, opt *ExecAttach) (*terminal.Session, error)

ContainerExecAttachTerminal attaches to an exec session and returns a terminal session bound to os.Stdin and os.Stdout.

Call Session.Start to copy I/O. Session.Close restores the terminal and closes the hijacked connection. Close is safe when Start never runs, and Start closes the session before it returns.

func (*Client) ContainerExecCreate

func (c *Client) ContainerExecCreate(ctx context.Context, containerID string, opt *Exec) (*response.ContainerExecCreate, error)

ContainerExecCreate creates a new exec configuration to run an exec process.

func (*Client) ContainerExecInspect

func (c *Client) ContainerExecInspect(ctx context.Context, id string) (*response.ContainerExecInspect, error)

ContainerExecInspect returns information about a specific exec process on the docker host.

func (*Client) ContainerExecResize

func (c *Client) ContainerExecResize(ctx context.Context, execID string, opt *Resize) error

ContainerExecResize changes the size of the tty for an exec process running inside a container.

func (*Client) ContainerExecStart

func (c *Client) ContainerExecStart(ctx context.Context, execID string, opt *ExecStart) error

ContainerExecStart starts an exec process already created in the docker host.

func (*Client) ContainerExport

func (c *Client) ContainerExport(ctx context.Context, id string) (io.ReadCloser, error)

ContainerExport retrieves the raw contents of a container and returns them as an io.ReadCloser. It's up to the caller to close the stream.

func (*Client) ContainerInspect

func (c *Client) ContainerInspect(ctx context.Context, id string) (*response.ContainerInspect, error)

ContainerInspect returns the container information.

func (*Client) ContainerKill

func (c *Client) ContainerKill(ctx context.Context, id string, signal string) error

ContainerKill terminates the container process but does not remove the container from the docker host.

func (*Client) ContainerList

func (c *Client) ContainerList(ctx context.Context, opt *List) ([]response.ContainerSummary, error)

ContainerList returns the list of containers in the docker host.

func (*Client) ContainerLogs

func (c *Client) ContainerLogs(ctx context.Context, id string, opt *Logs) (io.ReadCloser, error)

ContainerLogs returns the logs generated by a container in an io.ReadCloser. It's up to the caller to close the stream.

The stream format on the response will be in one of two formats:

If the container is using a TTY, there is only a single stream (stdout), and data is copied directly from the container output stream, no extra multiplexing or headers.

If the container is *not* using a TTY, streams for stdout and stderr are multiplexed. The format of the multiplexed stream is as follows:

[8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}

STREAM_TYPE can be 1 for stdout and 2 for stderr

SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian. This is the size of OUTPUT.

You can use github.com/moby/moby/api/pkg/stdcopy.StdCopy to demultiplex this stream.

func (*Client) ContainerPause

func (c *Client) ContainerPause(ctx context.Context, id string) error

ContainerPause pauses the main process of a given container without terminating it

func (*Client) ContainerPrune

func (c *Client) ContainerPrune(ctx context.Context, opt *Prune) (*response.ContainerPruneReport, error)

ContainerPrune requests the daemon to delete unused data

func (*Client) ContainerRemove

func (c *Client) ContainerRemove(ctx context.Context, id string, opt *Remove) error

ContainerRemove kills and removes a container from the docker host.

func (*Client) ContainerRename

func (c *Client) ContainerRename(ctx context.Context, id string, name string) error

ContainerRename changes the name or nickname of a container.

func (*Client) ContainerResize

func (c *Client) ContainerResize(ctx context.Context, id string, opt *Resize) error

ContainerResize changes the size of the tty for a container.

func (*Client) ContainerRestart

func (c *Client) ContainerRestart(ctx context.Context, id string, opt *Stop) error

ContainerRestart stops and starts a container again. It makes the daemon wait for the container to be up again for a specific amount of time, given the timeout.

func (*Client) ContainerStart

func (c *Client) ContainerStart(ctx context.Context, id string, opt *Start) error

ContainerStart sends a request to the docker daemon to start a container.

func (*Client) ContainerStatPath added in v0.5.0

func (c *Client) ContainerStatPath(ctx context.Context, id string, path string) (*response.ContainerPathStat, error)

ContainerStatPath returns filesystem metadata for one path inside the container.

func (*Client) ContainerStats

func (c *Client) ContainerStats(ctx context.Context, id string, stream bool) (*response.ContainerStatsReader, error)

ContainerStats returns near realtime stats for a given container. It's up to the caller to close the io.ReadCloser returned.

func (*Client) ContainerStatsOneShot

func (c *Client) ContainerStatsOneShot(ctx context.Context, id string) (*response.ContainerStatsOneShot, error)

ContainerStatsOneShot gets a single stat entry from a container. It differs from ContainerStats in that the API does not wait to prime the stats.

func (*Client) ContainerStop

func (c *Client) ContainerStop(ctx context.Context, id string, opt *Stop) error

ContainerStop stops a container. In case the container fails to stop gracefully within a time frame specified by the timeout argument, it is forcefully terminated (killed).

func (*Client) ContainerTop

func (c *Client) ContainerTop(ctx context.Context, id string, args ...string) (*response.ContainerTopResponse, error)

ContainerTop shows process information from within a container.

func (*Client) ContainerUnpause

func (c *Client) ContainerUnpause(ctx context.Context, id string) error

ContainerUnpause resumes the process execution within a container

func (*Client) ContainerUpdate

func (c *Client) ContainerUpdate(ctx context.Context, id string, opt *Update) (*response.ContainerUpdateResponse, error)

ContainerUpdate updates resources of a container.

func (*Client) ContainerWait

func (c *Client) ContainerWait(ctx context.Context, id string, condition WaitCondition) (<-chan response.ContainerWait, <-chan error)

ContainerWait waits until the specified container is in a certain state indicated by the given condition, either "not-running" (default), "next-exit", or "removed".

ContainerWait blocks until the request has been acknowledged by the server (with a response header), then returns two channels on which the caller can wait for the exit status of the container or an error if there was a problem either beginning the wait request or in getting the response. This allows the caller to synchronize ContainerWait with other calls, such as specifying a "next-exit" condition before issuing a ContainerStart request.

func (*Client) ContainerWaitSync

func (c *Client) ContainerWaitSync(ctx context.Context, id string, condition WaitCondition) error

ContainerWaitSync blocks until the container reaches the desired state, an error occurs, or the context is cancelled.

Returns nil if the container completes successfully or if the context is cancelled, and returns a non-nil error only if the container fails or Docker reports an error.

func (*Client) DaemonHost added in v0.5.0

func (c *Client) DaemonHost() string

DaemonHost returns the daemon address configured on the client.

func (*Client) DialHijack added in v0.5.0

func (c *Client) DialHijack(ctx context.Context, rawURL, proto string, meta map[string][]string) (net.Conn, error)

DialHijack opens a hijacked connection. proto is the Upgrade protocol, such as "tcp". meta is copied onto the request headers.

func (*Client) Dialer added in v0.5.0

func (c *Client) Dialer() func(context.Context) (net.Conn, error)

Dialer returns a dial function for a raw stream to the daemon.

func (*Client) DiskUsage added in v0.5.0

func (c *Client) DiskUsage(ctx context.Context, opt *DiskUsage) (*response.DiskUsage, error)

DiskUsage reports disk usage for the selected object types.

func (*Client) DistributionInspect added in v0.5.0

func (c *Client) DistributionInspect(ctx context.Context, ref string, opt *DistributionInspect) (*response.DistributionInspect, error)

DistributionInspect returns the image digest and manifest descriptor from the registry.

func (*Client) Events added in v0.5.0

func (c *Client) Events(ctx context.Context, opt *EngineEvents) (<-chan response.EngineEvent, <-chan error)

Events returns a stream of engine events. Cancel ctx to close the stream. The name is Engine-scoped so it does not collide with compose Events.

func (*Client) ImageAttestations added in v0.5.0

func (c *Client) ImageAttestations(ctx context.Context, ref string, opt *ImageAttestations) ([]response.ImageAttestation, error)

ImageAttestations returns in-toto statements attached to ref. This requires API 1.55.

func (*Client) ImageBuild

func (c *Client) ImageBuild(ctx context.Context, context io.Reader, opt *ImageBuild) (*response.ImageBuild, error)

ImageBuild sends a request to the daemon to build images. The Body in the response implements an io.ReadCloser and it's up to the caller to close it.

func (*Client) ImageCreate

func (c *Client) ImageCreate(ctx context.Context, ref string, opt *ImageCreate) (io.ReadCloser, error)

ImageCreate pulls ref and creates a local image. The engine no longer exposes a separate create call.

func (*Client) ImageHistory

func (c *Client) ImageHistory(ctx context.Context, ref string) ([]response.ImageHistoryItem, error)

ImageHistory returns the changes in an image in history format.

func (*Client) ImageImport

func (c *Client) ImageImport(ctx context.Context, ref string, opt *ImageImport) (io.ReadCloser, error)

ImageImport creates a new image based on the source options. It returns the JSON content in the response body.

func (*Client) ImageInspect

func (c *Client) ImageInspect(ctx context.Context, ref string, opt *ImageInspect) (*response.ImageInspect, error)

ImageInspect returns the image information. Nil options inspect without manifest or platform filters.

func (*Client) ImageList

func (c *Client) ImageList(ctx context.Context, opt *ImageList) ([]response.ImageSummary, error)

ImageList returns a list of images in the docker host.

Setting Manifests populates image summaries with manifest information. Identity requires API 1.54 and includes image identity with the manifests.

func (*Client) ImageLoad

func (c *Client) ImageLoad(ctx context.Context, opt *ImageLoad) (*response.ImageLoad, error)

ImageLoad loads an image in the docker host from the client host. It's up to the caller to close the io.ReadCloser in the ImageLoad response returned by this function.

Platforms selects which platforms to load from a multi-platform image.

func (*Client) ImagePull

func (c *Client) ImagePull(ctx context.Context, ref string, opt *ImagePull) (io.ReadCloser, error)

ImagePull requests the docker host to pull an image from a remote registry. It executes the privileged function if the operation is unauthorized and it tries one more time. It's up to the caller to handle the io.ReadCloser and close it properly.

func (*Client) ImagePush

func (c *Client) ImagePush(ctx context.Context, ref string, opt *ImagePush) (io.ReadCloser, error)

ImagePush requests the docker host to push an image to a remote registry. It executes the privileged function if the operation is unauthorized and it tries one more time. Nil options push with an empty auth header. It's up to the caller to handle the io.ReadCloser and close it properly.

func (*Client) ImageRemove

func (c *Client) ImageRemove(ctx context.Context, ref string, opt *ImageRemove) ([]response.ImageDelete, error)

ImageRemove removes an image from the docker host.

func (*Client) ImageSave

func (c *Client) ImageSave(ctx context.Context, opt *ImageSave) (io.ReadCloser, error)

ImageSave retrieves one or more images from the docker host as an io.ReadCloser.

func (*Client) ImageSearch

func (c *Client) ImageSearch(ctx context.Context, term string, opt *ImageSearch) ([]response.ImageSearchResult, error)

ImageSearch makes the docker host search by a term in a remote registry. The list of results is not sorted in any fashion.

func (*Client) ImageTag

func (c *Client) ImageTag(ctx context.Context, source, target string) error

ImageTag tags an image in the docker host.

func (*Client) ImagesPrune

func (c *Client) ImagesPrune(ctx context.Context, opt *ImagePrune) (*response.PruneReport, error)

ImagesPrune requests the daemon to delete unused data.

func (*Client) Info added in v0.5.0

func (c *Client) Info(ctx context.Context) (*response.Info, error)

Info returns daemon information.

func (*Client) NetworkConnect

func (c *Client) NetworkConnect(ctx context.Context, networkID string, opt *NetworkConnect) error

NetworkConnect connects a container to an existent network in the docker host.

func (*Client) NetworkCreate

func (c *Client) NetworkCreate(ctx context.Context, name string, opt *NetworkCreate) (*response.NetworkCreate, error)

NetworkCreate creates a new network in the docker host.

func (*Client) NetworkDisconnect

func (c *Client) NetworkDisconnect(ctx context.Context, networkID string, containerID string, force bool) error

NetworkDisconnect disconnects a container from an existent network in the docker host.

func (*Client) NetworkInspect

func (c *Client) NetworkInspect(ctx context.Context, networkID string, opt *NetworkInspect) (*response.NetworkInspect, error)

NetworkInspect returns the information for a specific network configured in the docker host.

func (*Client) NetworkList

func (c *Client) NetworkList(ctx context.Context, opt *NetworkList) ([]*response.NetworkSummary, error)

NetworkList returns the list of networks configured in the docker host.

func (*Client) NetworkRemove

func (c *Client) NetworkRemove(ctx context.Context, networkID string) error

NetworkRemove removes an existent network from the docker host.

func (*Client) NetworksPrune

func (c *Client) NetworksPrune(ctx context.Context, opt *NetworkPrune) (*response.NetworkPruneReport, error)

NetworksPrune requests the daemon to delete unused networks.

func (*Client) NodeInspect added in v0.5.0

func (c *Client) NodeInspect(ctx context.Context, id string) (*response.Node, error)

NodeInspect returns one swarm node. Raw is the daemon's JSON body.

func (*Client) NodeList added in v0.5.0

func (c *Client) NodeList(ctx context.Context, opt *NodeList) ([]response.Node, error)

NodeList returns the nodes in the swarm.

func (*Client) NodeRemove added in v0.5.0

func (c *Client) NodeRemove(ctx context.Context, id string, opt *NodeRemove) error

NodeRemove removes a swarm node.

func (*Client) NodeUpdate added in v0.5.0

func (c *Client) NodeUpdate(ctx context.Context, id string, opt *NodeUpdate) error

NodeUpdate updates a swarm node. Version must match the node's current object version.

func (*Client) Ping added in v0.5.0

func (c *Client) Ping(ctx context.Context, opt *Ping) (*response.Ping, error)

Ping checks that the daemon is reachable.

func (*Client) PluginCreate added in v0.5.0

func (c *Client) PluginCreate(ctx context.Context, createContext io.Reader, opt *PluginCreate) error

PluginCreate creates a plugin from a local rootfs tar. createContext is that tar.

func (*Client) PluginDisable added in v0.5.0

func (c *Client) PluginDisable(ctx context.Context, name string, opt *PluginDisable) error

PluginDisable disables a plugin.

func (*Client) PluginEnable added in v0.5.0

func (c *Client) PluginEnable(ctx context.Context, name string, opt *PluginEnable) error

PluginEnable enables a plugin.

func (*Client) PluginInspect added in v0.5.0

func (c *Client) PluginInspect(ctx context.Context, name string) (*response.Plugin, error)

PluginInspect returns one plugin. Raw is the daemon JSON.

func (*Client) PluginInstall added in v0.5.0

func (c *Client) PluginInstall(ctx context.Context, name string, opt *PluginInstall) (io.ReadCloser, error)

PluginInstall installs a plugin. The caller closes the progress stream.

func (*Client) PluginList added in v0.5.0

func (c *Client) PluginList(ctx context.Context, opt *PluginList) ([]response.Plugin, error)

PluginList returns plugins installed on the engine.

func (*Client) PluginPush added in v0.5.0

func (c *Client) PluginPush(ctx context.Context, name string, opt *PluginPush) (io.ReadCloser, error)

PluginPush pushes a plugin to a registry. The caller closes the progress stream.

func (*Client) PluginRemove added in v0.5.0

func (c *Client) PluginRemove(ctx context.Context, name string, opt *PluginRemove) error

PluginRemove removes a plugin.

func (*Client) PluginSet added in v0.5.0

func (c *Client) PluginSet(ctx context.Context, name string, opt *PluginSet) error

PluginSet sets plugin arguments.

func (*Client) PluginUpgrade added in v0.5.0

func (c *Client) PluginUpgrade(ctx context.Context, name string, opt *PluginUpgrade) (io.ReadCloser, error)

PluginUpgrade upgrades an installed plugin. The caller closes the progress stream.

func (*Client) RegistryLogin added in v0.5.0

func (c *Client) RegistryLogin(ctx context.Context, creds auth.Auth) (*response.RegistryLogin, error)

RegistryLogin authenticates against a registry.

func (*Client) SecretCreate added in v0.5.0

func (c *Client) SecretCreate(ctx context.Context, opt *SecretCreate) (string, error)

SecretCreate creates a swarm secret and returns its ID.

func (*Client) SecretInspect added in v0.5.0

func (c *Client) SecretInspect(ctx context.Context, id string) (*response.Secret, error)

SecretInspect returns one swarm secret. Raw is the daemon's JSON body.

func (*Client) SecretList added in v0.5.0

func (c *Client) SecretList(ctx context.Context, opt *SecretList) ([]response.Secret, error)

SecretList returns swarm secrets.

func (*Client) SecretRemove added in v0.5.0

func (c *Client) SecretRemove(ctx context.Context, id string) error

SecretRemove removes a swarm secret.

func (*Client) SecretUpdate added in v0.5.0

func (c *Client) SecretUpdate(ctx context.Context, id string, opt *SecretUpdate) error

SecretUpdate updates a swarm secret.

func (*Client) ServerVersion added in v0.5.0

func (c *Client) ServerVersion(ctx context.Context) (*response.ServerVersion, error)

ServerVersion returns the daemon version.

func (*Client) ServiceCreate added in v0.5.0

func (c *Client) ServiceCreate(ctx context.Context, opt *ServiceCreate) (*response.ServiceCreate, error)

ServiceCreate creates a swarm service.

func (*Client) ServiceInspect added in v0.5.0

func (c *Client) ServiceInspect(ctx context.Context, id string, opt *ServiceInspect) (*response.Service, error)

ServiceInspect returns one swarm service. Raw is the daemon's JSON body.

func (*Client) ServiceList added in v0.5.0

func (c *Client) ServiceList(ctx context.Context, opt *ServiceList) ([]response.Service, error)

ServiceList returns swarm services.

func (*Client) ServiceLogs added in v0.5.0

func (c *Client) ServiceLogs(ctx context.Context, id string, opt *ServiceLogs) (io.ReadCloser, error)

ServiceLogs returns the logs of a swarm service. The caller closes the stream.

func (*Client) ServiceRemove added in v0.5.0

func (c *Client) ServiceRemove(ctx context.Context, id string) error

ServiceRemove removes a swarm service.

func (*Client) ServiceUpdate added in v0.5.0

func (c *Client) ServiceUpdate(ctx context.Context, id string, opt *ServiceUpdate) (*response.ServiceUpdate, error)

ServiceUpdate updates a swarm service.

func (*Client) SwarmGetUnlockKey added in v0.5.0

func (c *Client) SwarmGetUnlockKey(ctx context.Context) (string, error)

SwarmGetUnlockKey returns the swarm manager unlock key.

func (*Client) SwarmInit

func (c *Client) SwarmInit(ctx context.Context, opt *SwarmInit) (string, error)

SwarmInit initializes the swarm and returns the node ID.

func (*Client) SwarmInspect

func (c *Client) SwarmInspect(ctx context.Context) (*response.Swarm, error)

SwarmInspect inspects the swarm.

func (*Client) SwarmJoin

func (c *Client) SwarmJoin(ctx context.Context, opt *SwarmJoin) error

SwarmJoin joins a node to the swarm.

func (*Client) SwarmLeave

func (c *Client) SwarmLeave(ctx context.Context, force bool) error

SwarmLeave leaves the swarm.

func (*Client) SwarmUnlock added in v0.5.0

func (c *Client) SwarmUnlock(ctx context.Context, opt *SwarmUnlock) error

SwarmUnlock unlocks a locked swarm manager.

func (*Client) SwarmUpdate added in v0.5.0

func (c *Client) SwarmUpdate(ctx context.Context, opt *SwarmUpdate) error

SwarmUpdate updates the swarm spec and can rotate tokens or the unlock key.

func (*Client) TaskInspect added in v0.5.0

func (c *Client) TaskInspect(ctx context.Context, id string) (*response.Task, error)

TaskInspect returns one swarm task. Raw is the daemon's JSON body.

func (*Client) TaskList added in v0.5.0

func (c *Client) TaskList(ctx context.Context, opt *TaskList) ([]response.Task, error)

TaskList returns swarm tasks.

func (*Client) TaskLogs added in v0.5.0

func (c *Client) TaskLogs(ctx context.Context, id string, opt *TaskLogs) (io.ReadCloser, error)

TaskLogs returns the logs of one swarm task. The caller closes the stream.

func (*Client) Unwrap

func (c *Client) Unwrap() *sdk.Client

Unwrap returns the underlying Engine API client.

func (*Client) VolumeCreate

func (c *Client) VolumeCreate(ctx context.Context, opt *VolumeCreate) (*response.Volume, error)

VolumeCreate creates a volume in the docker host.

func (*Client) VolumeInspect

func (c *Client) VolumeInspect(ctx context.Context, name string) (*response.Volume, error)

VolumeInspect returns the information about a specific volume in the docker host.

func (*Client) VolumeInspectWithRaw

func (c *Client) VolumeInspectWithRaw(ctx context.Context, name string) (*response.Volume, []byte, error)

VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation.

func (*Client) VolumeList

func (c *Client) VolumeList(ctx context.Context, opt *VolumeList) (*response.VolumeList, error)

VolumeList returns the volumes configured in the docker host.

func (*Client) VolumeRemove

func (c *Client) VolumeRemove(ctx context.Context, name string, force bool) error

VolumeRemove removes a volume from the docker host.

func (*Client) VolumeUpdate

func (c *Client) VolumeUpdate(ctx context.Context, name string, swarmVersionIndex uint64, opt *VolumeUpdate) error

VolumeUpdate updates a volume. This only works for Cluster Volumes, and only some fields can be updated.

func (*Client) VolumesPrune

func (c *Client) VolumesPrune(ctx context.Context, opt *VolumePrune) (*response.VolumePruneReport, error)

VolumesPrune requests the daemon to delete unused data.

type ConfigCreate added in v0.5.0

type ConfigCreate sdk.ConfigCreateOptions

ConfigCreate is sdk.ConfigCreateOptions.

type ConfigList added in v0.5.0

type ConfigList sdk.ConfigListOptions

ConfigList is sdk.ConfigListOptions.

type ConfigUpdate added in v0.5.0

type ConfigUpdate sdk.ConfigUpdateOptions

ConfigUpdate is sdk.ConfigUpdateOptions.

type ConsoleSize added in v0.6.1

type ConsoleSize = sdk.ConsoleSize

ConsoleSize is sdk.ConsoleSize.

type CopyTo

CopyTo is sdk.CopyToContainerOptions. DestinationPath is filled from the method argument.

type DiskUsage added in v0.5.0

type DiskUsage sdk.DiskUsageOptions

DiskUsage is sdk.DiskUsageOptions. Nil options report containers, images, volumes, and build cache.

type DistributionInspect added in v0.5.0

type DistributionInspect sdk.DistributionInspectOptions

DistributionInspect is sdk.DistributionInspectOptions.

type EngineEvents added in v0.5.0

type EngineEvents sdk.EventsListOptions

EngineEvents is sdk.EventsListOptions. Nil watches every event.

type ExecAttach

type ExecAttach sdk.ExecAttachOptions

ExecAttach is sdk.ExecAttachOptions.

type ExecStart

type ExecStart sdk.ExecStartOptions

ExecStart is sdk.ExecStartOptions.

type Filters added in v0.6.1

type Filters = sdk.Filters

Filters is sdk.Filters.

type ImageAttestations added in v0.5.0

type ImageAttestations struct {
	Platform       *ocispec.Platform
	PredicateTypes []string
}

ImageAttestations is options for ImageAttestations. The SDK uses functional options.

type ImageBuild

type ImageBuild sdk.ImageBuildOptions

ImageBuild is sdk.ImageBuildOptions.

type ImageCreate

type ImageCreate sdk.ImagePullOptions

ImageCreate is sdk.ImagePullOptions. The engine creates the image by pulling ref.

type ImageImport

type ImageImport struct {
	Source     io.Reader
	SourceName string
	Tag        string
	Message    string
	Changes    []string
	Platform   ocispec.Platform
}

ImageImport combines sdk.ImageImportSource and sdk.ImageImportOptions.

type ImageInspect added in v0.5.0

type ImageInspect struct {
	Manifests bool
	Platform  *ocispec.Platform
}

ImageInspect is options for ImageInspect. The SDK uses functional options.

type ImageList

type ImageList sdk.ImageListOptions

ImageList is sdk.ImageListOptions.

type ImageLoad

type ImageLoad struct {
	Input     io.Reader
	Quiet     bool
	Platforms []ocispec.Platform
}

ImageLoad is options for ImageLoad. The SDK takes the input reader as a method argument plus functional options.

type ImagePrune

type ImagePrune sdk.ImagePruneOptions

ImagePrune is sdk.ImagePruneOptions.

type ImagePull

type ImagePull sdk.ImagePullOptions

ImagePull is sdk.ImagePullOptions.

type ImagePush added in v0.5.0

type ImagePush sdk.ImagePushOptions

ImagePush is sdk.ImagePushOptions.

type ImageRemove

type ImageRemove sdk.ImageRemoveOptions

ImageRemove is sdk.ImageRemoveOptions.

type ImageSave

type ImageSave struct {
	ImageIDs  []string
	Platforms []ocispec.Platform
}

ImageSave is options for ImageSave. The SDK takes image IDs as a method argument plus functional options; this struct holds both.

type ImageSearch

type ImageSearch sdk.ImageSearchOptions

ImageSearch is sdk.ImageSearchOptions.

type List

List is sdk.ContainerListOptions. Latest sets Limit to 1 when Limit is 0. Since and Before are also sent as filters.

type LogCopier

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

LogCopier provides methods to copy Docker container logs

func NewLogCopier

func NewLogCopier(stdout io.Writer, stderr io.Writer) *LogCopier

NewLogCopier creates a new LogCopier instance for multiplexed streams If stderr is nil, it will use stdout for both streams

func (*LogCopier) Copy

func (lc *LogCopier) Copy(src io.Reader) (written int64, err error)

Copy copies the container log stream to the configured writers It handles Docker's multiplexed output format where stdout and stderr are combined with headers

func (*LogCopier) CopyWithPrefix

func (lc *LogCopier) CopyWithPrefix(src io.Reader, stdoutPrefix, stderrPrefix string) (written int64, err error)

CopyWithPrefix copies the container log stream and adds prefixes to stdout and stderr This is useful when you want to distinguish between the two streams in the output

type NetworkConnect

type NetworkConnect sdk.NetworkConnectOptions

NetworkConnect is sdk.NetworkConnectOptions.

type NetworkCreate

type NetworkCreate sdk.NetworkCreateOptions

NetworkCreate is sdk.NetworkCreateOptions.

type NetworkInspect

type NetworkInspect sdk.NetworkInspectOptions

NetworkInspect is sdk.NetworkInspectOptions.

type NetworkList

type NetworkList sdk.NetworkListOptions

NetworkList is sdk.NetworkListOptions.

type NetworkPrune

type NetworkPrune sdk.NetworkPruneOptions

NetworkPrune is sdk.NetworkPruneOptions.

type NodeList added in v0.5.0

type NodeList sdk.NodeListOptions

NodeList is sdk.NodeListOptions.

type NodeRemove added in v0.5.0

type NodeRemove sdk.NodeRemoveOptions

NodeRemove is sdk.NodeRemoveOptions.

type NodeUpdate added in v0.5.0

type NodeUpdate sdk.NodeUpdateOptions

NodeUpdate is sdk.NodeUpdateOptions.

type Ping added in v0.5.0

type Ping sdk.PingOptions

Ping is sdk.PingOptions. Nil leaves API version negotiation to the client constructor.

type PluginCreate added in v0.5.0

type PluginCreate sdk.PluginCreateOptions

PluginCreate is sdk.PluginCreateOptions.

type PluginDisable added in v0.5.0

type PluginDisable sdk.PluginDisableOptions

PluginDisable is sdk.PluginDisableOptions.

type PluginEnable added in v0.5.0

type PluginEnable sdk.PluginEnableOptions

PluginEnable is sdk.PluginEnableOptions.

type PluginInstall added in v0.5.0

type PluginInstall sdk.PluginInstallOptions

PluginInstall is sdk.PluginInstallOptions.

type PluginList added in v0.5.0

type PluginList sdk.PluginListOptions

PluginList is sdk.PluginListOptions.

type PluginPush added in v0.5.0

type PluginPush sdk.PluginPushOptions

PluginPush is sdk.PluginPushOptions.

type PluginRemove added in v0.5.0

type PluginRemove sdk.PluginRemoveOptions

PluginRemove is sdk.PluginRemoveOptions.

type PluginSet added in v0.5.0

type PluginSet sdk.PluginSetOptions

PluginSet is sdk.PluginSetOptions.

type PluginUpgrade added in v0.5.0

type PluginUpgrade sdk.PluginUpgradeOptions

PluginUpgrade is sdk.PluginUpgradeOptions.

type SecretCreate added in v0.5.0

type SecretCreate sdk.SecretCreateOptions

SecretCreate is sdk.SecretCreateOptions.

type SecretList added in v0.5.0

type SecretList sdk.SecretListOptions

SecretList is sdk.SecretListOptions.

type SecretUpdate added in v0.5.0

type SecretUpdate sdk.SecretUpdateOptions

SecretUpdate is sdk.SecretUpdateOptions.

type ServiceCreate added in v0.5.0

type ServiceCreate sdk.ServiceCreateOptions

ServiceCreate is sdk.ServiceCreateOptions.

type ServiceInspect added in v0.5.0

type ServiceInspect sdk.ServiceInspectOptions

ServiceInspect is sdk.ServiceInspectOptions.

type ServiceList added in v0.5.0

type ServiceList sdk.ServiceListOptions

ServiceList is sdk.ServiceListOptions.

type ServiceLogs added in v0.5.0

type ServiceLogs sdk.ServiceLogsOptions

ServiceLogs is sdk.ServiceLogsOptions.

type ServiceUpdate added in v0.5.0

type ServiceUpdate sdk.ServiceUpdateOptions

ServiceUpdate is sdk.ServiceUpdateOptions.

type SetClientOption

type SetClientOption = sdk.Opt

SetClientOption is a configuration option to initialize a Client.

func FromEnv

func FromEnv() SetClientOption

FromEnv configures the client with values from environment variables. It is the equivalent of using the WithTLSClientConfigFromEnv, WithHostFromEnv, and [WithVersionFromEnv] options.

FromEnv uses the following environment variables:

  • DOCKER_HOST to set the URL to the docker server.
  • DOCKER_API_VERSION to set the version of the API to use, leave empty for latest.
  • DOCKER_CERT_PATH to specify the directory from which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem").
  • DOCKER_TLS_VERIFY to enable or disable TLS verification (off by default).

func WithAPIVersion added in v0.5.0

func WithAPIVersion(version string) SetClientOption

WithAPIVersion overrides the client version with the specified one. If an empty version is provided, the value is ignored to allow version negotiation (see WithAPIVersionNegotiation).

func WithAPIVersionFromEnv added in v0.5.0

func WithAPIVersionFromEnv() SetClientOption

WithAPIVersionFromEnv overrides the client version with the version specified in the DOCKER_API_VERSION environment variable. If DOCKER_API_VERSION is not set, or set to an empty value, the version is not modified.

func WithAPIVersionNegotiation

func WithAPIVersionNegotiation() SetClientOption

WithAPIVersionNegotiation leaves the API version unset so the client negotiates with the daemon.

func WithDialContext

func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) SetClientOption

WithDialContext applies the dialer to the client transport. This can be used to set the Timeout and KeepAlive settings of the client. It returns an error if the client does not have an http.Transport configured.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) SetClientOption

WithHTTPClient overrides the client's HTTP client with the specified one.

func WithHTTPHeaders

func WithHTTPHeaders(headers map[string]string) SetClientOption

WithHTTPHeaders appends custom HTTP headers to the client's default headers. It does not allow for built-in headers (such as "User-Agent", if set) to be overridden. Also see WithUserAgent.

func WithHost

func WithHost(host string) SetClientOption

WithHost overrides the client host with the specified one.

func WithHostFromEnv

func WithHostFromEnv() SetClientOption

WithHostFromEnv overrides the client host with the host specified in the DOCKER_HOST environment variable. If DOCKER_HOST is not set, or set to an empty value, the host is not modified.

func WithScheme

func WithScheme(scheme string) SetClientOption

WithScheme overrides the client scheme with the specified one.

func WithTLSClientConfig

func WithTLSClientConfig(cacertPath, certPath, keyPath string) SetClientOption

WithTLSClientConfig applies a TLS config to the client transport.

func WithTLSClientConfigFromEnv

func WithTLSClientConfigFromEnv() SetClientOption

WithTLSClientConfigFromEnv configures the client's TLS settings with the settings in the DOCKER_CERT_PATH and DOCKER_TLS_VERIFY environment variables. If DOCKER_CERT_PATH is not set or empty, TLS configuration is not modified.

func WithTimeout

func WithTimeout(timeout time.Duration) SetClientOption

WithTimeout configures the time limit for requests made by the HTTP client.

func WithTraceOptions

func WithTraceOptions(opts ...otelhttp.Option) SetClientOption

WithTraceOptions sets tracing span options for the client.

func WithTraceProvider

func WithTraceProvider(provider trace.TracerProvider) SetClientOption

WithTraceProvider sets the trace provider for the client. If this is not set then the global trace provider will be used.

func WithUserAgent

func WithUserAgent(userAgent string) SetClientOption

WithUserAgent configures the User-Agent header to use for HTTP requests. It overrides any User-Agent set in headers. When set to an empty string, the User-Agent header is removed, and no header is sent.

type SwarmInit

type SwarmInit sdk.SwarmInitOptions

SwarmInit is sdk.SwarmInitOptions.

type SwarmJoin

type SwarmJoin sdk.SwarmJoinOptions

SwarmJoin is sdk.SwarmJoinOptions.

type SwarmUnlock added in v0.5.0

type SwarmUnlock sdk.SwarmUnlockOptions

SwarmUnlock is sdk.SwarmUnlockOptions.

type SwarmUpdate added in v0.5.0

type SwarmUpdate sdk.SwarmUpdateOptions

SwarmUpdate is sdk.SwarmUpdateOptions.

type TaskList added in v0.5.0

type TaskList sdk.TaskListOptions

TaskList is sdk.TaskListOptions.

type TaskLogs added in v0.5.0

type TaskLogs sdk.TaskLogsOptions

TaskLogs is sdk.TaskLogsOptions.

type VolumeCreate

type VolumeCreate sdk.VolumeCreateOptions

VolumeCreate is sdk.VolumeCreateOptions.

type VolumeList

type VolumeList sdk.VolumeListOptions

VolumeList is sdk.VolumeListOptions.

type VolumePrune

type VolumePrune sdk.VolumePruneOptions

VolumePrune is sdk.VolumePruneOptions.

type VolumeUpdate

type VolumeUpdate sdk.VolumeUpdateOptions

VolumeUpdate is sdk.VolumeUpdateOptions. Version is filled from the method argument.

type WaitCondition

type WaitCondition = container.WaitCondition

WaitCondition is container.WaitCondition.

Directories

Path Synopsis
Package response provides thin wrappers around the docker client response types.
Package response provides thin wrappers around the docker client response types.
Package terminal attaches a local terminal to a hijacked container stream.
Package terminal attaches a local terminal to a hijacked container stream.

Jump to

Keyboard shortcuts

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