[go: up one dir, main page]

client

package module
v0.1.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 48 Imported by: 230

README

Go client for the Docker Engine API

PkgGoDev GitHub License Go Report Card OpenSSF Scorecard OpenSSF Best Practices

The docker command uses this package to communicate with the daemon. It can also be used by your own Go applications to do anything the command-line interface does; running containers, pulling or pushing images, etc.

For example, to list all containers (the equivalent of docker ps --all):

package main

import (
	"context"
	"fmt"

	"github.com/moby/moby/client"
)

func main() {
	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
	if err != nil {
		panic(err)
	}
	defer apiClient.Close()

	containers, err := apiClient.ContainerList(context.Background(), client.ContainerListOptions{All: true})
	if err != nil {
		panic(err)
	}

	for _, ctr := range containers {
		fmt.Printf("%s %s (status: %s)\n", ctr.ID, ctr.Image, ctr.Status)
	}
}

Full documentation is available on pkg.go.dev.

Documentation

Overview

Package client is a Go client for the Docker Engine API.

For more information about the Engine API, see the documentation: https://docs.docker.com/reference/api/engine/

Usage

You use the library by constructing a client object using NewClientWithOpts and calling methods on it. The client can be configured from environment variables by passing the FromEnv option, or configured manually by passing any of the other available [Opts].

For example, to list running containers (the equivalent of "docker ps"):

package main

import (
	"context"
	"fmt"

	"github.com/moby/moby/client"
)

func main() {
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		panic(err)
	}

	containers, err := cli.ContainerList(context.Background(), client.ContainerListOptions{})
	if err != nil {
		panic(err)
	}

	for _, ctr := range containers {
		fmt.Printf("%s %s\n", ctr.ID, ctr.Image)
	}
}

Index

Examples

Constants

View Source
const (
	// EnvOverrideHost is the name of the environment variable that can be used
	// to override the default host to connect to (DefaultDockerHost).
	//
	// This env-var is read by [FromEnv] and [WithHostFromEnv] and when set to a
	// non-empty value, takes precedence over the default host (which is platform
	// specific), or any host already set.
	EnvOverrideHost = "DOCKER_HOST"

	// EnvOverrideAPIVersion is the name of the environment variable that can
	// be used to override the API version to use. Value must be
	// formatted as MAJOR.MINOR, for example, "1.19".
	//
	// This env-var is read by [FromEnv] and [WithVersionFromEnv] and when set to a
	// non-empty value, takes precedence over API version negotiation.
	//
	// This environment variable should be used for debugging purposes only, as
	// it can set the client to use an incompatible (or invalid) API version.
	EnvOverrideAPIVersion = "DOCKER_API_VERSION"

	// EnvOverrideCertPath is the name of the environment variable that can be
	// used to specify the directory from which to load the TLS certificates
	// (ca.pem, cert.pem, key.pem) from. These certificates are used to configure
	// the [Client] for a TCP connection protected by TLS client authentication.
	//
	// TLS certificate verification is enabled by default if the Client is configured
	// to use a TLS connection. Refer to [EnvTLSVerify] below to learn how to
	// disable verification for testing purposes.
	//
	// WARNING: Access to the remote API is equivalent to root access to the
	// host where the daemon runs. Do not expose the API without protection,
	// and only if needed. Make sure you are familiar with the ["daemon attack surface"].
	//
	// For local access to the API, it is recommended to connect with the daemon
	// using the default local socket connection (on Linux), or the named pipe
	// (on Windows).
	//
	// If you need to access the API of a remote daemon, consider using an SSH
	// (ssh://) connection, which is easier to set up, and requires no additional
	// configuration if the host is accessible using ssh.
	//
	// If you cannot use the alternatives above, and you must expose the API over
	// a TCP connection. Refer to [Protect the Docker daemon socket]
	// to learn how to configure the daemon and client to use a TCP connection
	// with TLS client authentication. Make sure you know the differences between
	// a regular TLS connection and a TLS connection protected by TLS client
	// authentication, and verify that the API cannot be accessed by other clients.
	//
	// ["daemon attack surface"]: https://docs.docker.com/go/attack-surface/
	// [Protect the Docker daemon socket]: https://docs.docker.com/engine/security/protect-access/
	EnvOverrideCertPath = "DOCKER_CERT_PATH"

	// EnvTLSVerify is the name of the environment variable that can be used to
	// enable or disable TLS certificate verification. When set to a non-empty
	// value, TLS certificate verification is enabled, and the client is configured
	// to use a TLS connection, using certificates from the default directories
	// (within `~/.docker`); refer to EnvOverrideCertPath above for additional
	// details.
	//
	// WARNING: Access to the remote API is equivalent to root access to the
	// host where the daemon runs. Do not expose the API without protection,
	// and only if needed. Make sure you are familiar with the ["daemon attack surface"].
	//
	// Before setting up your client and daemon to use a TCP connection with TLS
	// client authentication, consider using one of the alternatives mentioned
	// in [EnvOverrideCertPath].
	//
	// Disabling TLS certificate verification (for testing purposes)
	//
	// TLS certificate verification is enabled by default if the Client is configured
	// to use a TLS connection, and it is highly recommended to keep verification
	// enabled to prevent machine-in-the-middle attacks. Refer to [Protect the Docker daemon socket]
	// in the documentation and pages linked from that page to learn how to
	// configure the daemon and client to use a TCP connection with TLS client
	// authentication enabled.
	//
	// Set the "DOCKER_TLS_VERIFY" environment to an empty string ("") to
	// disable TLS certificate verification. Disabling verification is insecure,
	// so should only be done for testing purposes.
	//
	// From the[crypto/tls.Config] documentation:
	//
	// InsecureSkipVerify controls whether a client verifies the server's
	// certificate chain and host name. If InsecureSkipVerify is true, crypto/tls
	// accepts any certificate presented by the server and any host name in that
	// certificate. In this mode, TLS is susceptible to machine-in-the-middle
	// attacks unless custom verification is used. This should be used only for
	// testing or in combination with VerifyConnection or VerifyPeerCertificate.
	//
	// ["daemon attack surface"]: https://docs.docker.com/go/attack-surface/
	// [Protect the Docker daemon socket]: https://docs.docker.com/engine/security/protect-access/
	EnvTLSVerify = "DOCKER_TLS_VERIFY"
)
View Source
const DefaultDockerHost = "unix:///var/run/docker.sock"

DefaultDockerHost defines OS-specific default host if the DOCKER_HOST (EnvOverrideHost) environment variable is unset or empty.

View Source
const DummyHost = "api.moby.localhost"

DummyHost is a hostname used for local communication.

It acts as a valid formatted hostname for local connections (such as "unix://" or "npipe://") which do not require a hostname. It should never be resolved, but uses the special-purpose ".localhost" TLD (as defined in RFC 2606, Section 2 and RFC 6761, Section 6.3).

RFC 7230, Section 5.4 defines that an empty header must be used for such cases:

If the authority component is missing or undefined for the target URI,
then a client MUST send a Host header field with an empty field-value.

However, Go stdlib enforces the semantics of HTTP(S) over TCP, does not allow an empty header to be used, and requires req.URL.Scheme to be either "http" or "https".

For further details, refer to:

View Source
const MaxAPIVersion = "1.52"

MaxAPIVersion is the highest REST API version supported by the client. If API-version negotiation is enabled (see WithAPIVersionNegotiation, Client.NegotiateAPIVersion), the client may downgrade its API version. Similarly, the WithVersion and WithVersionFromEnv allow overriding the version.

This version may be lower than the version of the api library module used.

Variables

View Source
var ErrRedirect = errors.New("unexpected redirect in response")

ErrRedirect is the error returned by checkRedirect when the request is non-GET.

Functions

func CheckRedirect

func CheckRedirect(_ *http.Request, via []*http.Request) error

CheckRedirect specifies the policy for dealing with redirect responses. It can be set on http.Client.CheckRedirect to prevent HTTP redirects for non-GET requests. It returns an ErrRedirect for non-GET request, otherwise returns a http.ErrUseLastResponse, which is special-cased by http.Client to use the last response.

Go 1.8 changed behavior for HTTP redirects (specifically 301, 307, and 308) in the client. The client (and by extension API client) can be made to send a request like "POST /containers//start" where what would normally be in the name section of the URL is empty. This triggers an HTTP 301 from the daemon.

In go 1.8 this 301 is converted to a GET request, and ends up getting a 404 from the daemon. This behavior change manifests in the client in that before, the 301 was not followed and the client did not generate an error, but now results in a message like "Error response from daemon: page not found".

func FromEnv

func FromEnv(c *clientConfig) error

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 (EnvOverrideHost) to set the URL to the docker server.
  • DOCKER_API_VERSION (EnvOverrideAPIVersion) to set the version of the API to use, leave empty for latest.
  • DOCKER_CERT_PATH (EnvOverrideCertPath) to specify the directory from which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem').
  • DOCKER_TLS_VERIFY (EnvTLSVerify) to enable or disable TLS verification (off by default).

func IsErrConnectionFailed

func IsErrConnectionFailed(err error) bool

IsErrConnectionFailed returns true if the error is caused by connection failed.

func ParseHostURL

func ParseHostURL(host string) (*url.URL, error)

ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL

Types

type APIClient

type APIClient interface {
	CheckpointAPIClient // CheckpointAPIClient is still experimental.
	// contains filtered or unexported methods
}

APIClient is an interface that clients that talk with a docker server must implement.

type BuildCachePruneOptions

type BuildCachePruneOptions struct {
	All           bool
	ReservedSpace int64
	MaxUsedSpace  int64
	MinFreeSpace  int64
	Filters       filters.Args
}

BuildCachePruneOptions hold parameters to prune the build cache.

type CheckpointAPIClient

type CheckpointAPIClient interface {
	CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) error
	CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error
	CheckpointList(ctx context.Context, container string, options CheckpointListOptions) ([]checkpoint.Summary, error)
}

CheckpointAPIClient defines API client methods for the checkpoints.

Experimental: checkpoint and restore is still an experimental feature, and only available if the daemon is running with experimental features enabled.

type CheckpointCreateOptions

type CheckpointCreateOptions struct {
	CheckpointID  string
	CheckpointDir string
	Exit          bool
}

CheckpointCreateOptions holds parameters to create a checkpoint from a container.

type CheckpointDeleteOptions

type CheckpointDeleteOptions struct {
	CheckpointID  string
	CheckpointDir string
}

CheckpointDeleteOptions holds parameters to delete a checkpoint from a container.

type CheckpointListOptions

type CheckpointListOptions struct {
	CheckpointDir string
}

CheckpointListOptions holds parameters to list checkpoints for a container.

type Client

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

Client is the API client that performs all operations against a docker server.

func NewClientWithOpts

func NewClientWithOpts(ops ...Opt) (*Client, error)

NewClientWithOpts initializes a new API client with a default HTTPClient, and default API host and version. It also initializes the custom HTTP headers to add to each request.

It takes an optional list of Opt functional arguments, which are applied in the order they're provided, which allows modifying the defaults when creating the client. For example, the following initializes a client that configures itself with values from environment variables (FromEnv), and has automatic API version negotiation enabled (WithAPIVersionNegotiation).

cli, err := client.NewClientWithOpts(
	client.FromEnv,
	client.WithAPIVersionNegotiation(),
)

func (*Client) BuildCachePrune

func (cli *Client) BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (*build.CachePruneReport, error)

BuildCachePrune requests the daemon to delete unused cache data.

func (*Client) BuildCancel

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

BuildCancel requests the daemon to cancel the ongoing build request with the given id.

func (*Client) CheckpointCreate

func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) error

CheckpointCreate creates a checkpoint from the given container.

func (*Client) CheckpointDelete

func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options CheckpointDeleteOptions) error

CheckpointDelete deletes the checkpoint with the given name from the given container.

func (*Client) CheckpointList

func (cli *Client) CheckpointList(ctx context.Context, container string, options CheckpointListOptions) ([]checkpoint.Summary, error)

CheckpointList returns the checkpoints of the given container in the docker host.

func (*Client) ClientVersion

func (cli *Client) ClientVersion() string

ClientVersion returns the API version used by this client.

func (*Client) Close

func (cli *Client) Close() error

Close the transport used by the client

func (*Client) ConfigCreate

func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)

ConfigCreate creates a new config.

func (*Client) ConfigInspectWithRaw

func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error)

ConfigInspectWithRaw returns the config information with raw data

func (*Client) ConfigList

func (cli *Client) ConfigList(ctx context.Context, options ConfigListOptions) ([]swarm.Config, error)

ConfigList returns the list of configs.

func (*Client) ConfigRemove

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

ConfigRemove removes a config.

func (*Client) ConfigUpdate

func (cli *Client) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error

ConfigUpdate attempts to update a config

func (*Client) ContainerAttach

func (cli *Client) ContainerAttach(ctx context.Context, containerID string, options ContainerAttachOptions) (HijackedResponse, error)

ContainerAttach attaches a connection to a container in the server. It returns a HijackedResponse with the hijacked connection and a reader to get output. It's up to the called to close the hijacked connection by calling HijackedResponse.Close.

The stream format on the response uses 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 defined in the stdcopy package, and 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. Refer to stdcopy.StdType for details. SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian, this is the size of OUTPUT. You can use stdcopy.StdCopy to demultiplex this stream.

func (*Client) ContainerCommit

func (cli *Client) ContainerCommit(ctx context.Context, containerID string, options ContainerCommitOptions) (container.CommitResponse, error)

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

func (*Client) ContainerCreate

func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, 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 (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.FilesystemChange, error)

ContainerDiff shows differences in a container filesystem since it was started.

func (*Client) ContainerExecAttach

func (cli *Client) ContainerExecAttach(ctx context.Context, execID string, config container.ExecAttachOptions) (HijackedResponse, error)

ContainerExecAttach attaches a connection to an exec process in the server.

It returns a HijackedResponse with the hijacked connection and a reader to get output. It's up to the called to close the hijacked connection by calling HijackedResponse.Close.

The stream format on the response uses 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.

You can use stdcopy.StdCopy to demultiplex this stream. Refer to Client.ContainerAttach for details about the multiplexed stream.

func (*Client) ContainerExecCreate

func (cli *Client) ContainerExecCreate(ctx context.Context, containerID string, options container.ExecOptions) (container.ExecCreateResponse, error)

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

func (*Client) ContainerExecInspect

func (cli *Client) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)

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

func (*Client) ContainerExecResize

func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) error

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

func (*Client) ContainerExecStart

func (cli *Client) ContainerExecStart(ctx context.Context, execID string, config container.ExecStartOptions) error

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

func (*Client) ContainerExport

func (cli *Client) ContainerExport(ctx context.Context, containerID 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 (cli *Client) ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)

ContainerInspect returns the container information.

func (*Client) ContainerInspectWithRaw

func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (container.InspectResponse, []byte, error)

ContainerInspectWithRaw returns the container information and its raw representation.

func (*Client) ContainerKill

func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error

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

func (*Client) ContainerList

func (cli *Client) ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error)

ContainerList returns the list of containers in the docker host.

func (*Client) ContainerLogs

func (cli *Client) ContainerLogs(ctx context.Context, containerID string, options ContainerLogsOptions) (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 uses 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 defined in the stdcopy package, and 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. Refer to stdcopy.StdType for details. SIZE1, SIZE2, SIZE3, and SIZE4 are four bytes of uint32 encoded as big endian, this is the size of OUTPUT. You can use stdcopy.StdCopy to demultiplex this stream.

Example (WithTimeout)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

client, _ := NewClientWithOpts(FromEnv)
reader, err := client.ContainerLogs(ctx, "container_id", ContainerLogsOptions{})
if err != nil {
	log.Fatal(err)
}

_, err = io.Copy(os.Stdout, reader)
if err != nil && !errors.Is(err, io.EOF) {
	log.Fatal(err)
}

func (*Client) ContainerPause

func (cli *Client) ContainerPause(ctx context.Context, containerID string) error

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

func (*Client) ContainerRemove

func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) error

ContainerRemove kills and removes a container from the docker host.

func (*Client) ContainerRename

func (cli *Client) ContainerRename(ctx context.Context, containerID, newContainerName string) error

ContainerRename changes the name of a given container.

func (*Client) ContainerResize

func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) error

ContainerResize changes the size of the pseudo-TTY for a container.

func (*Client) ContainerRestart

func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options ContainerStopOptions) 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 (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) error

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

func (*Client) ContainerStatPath

func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path string) (container.PathStat, error)

ContainerStatPath returns stat information about a path inside the container filesystem.

func (*Client) ContainerStats

func (cli *Client) ContainerStats(ctx context.Context, containerID string, stream bool) (StatsResponseReader, 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 (cli *Client) ContainerStatsOneShot(ctx context.Context, containerID string) (StatsResponseReader, error)

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

func (*Client) ContainerStop

func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) 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).

If the timeout is nil, the container's StopTimeout value is used, if set, otherwise the engine default. A negative timeout value can be specified, meaning no timeout, i.e. no forceful termination is performed.

func (*Client) ContainerTop

func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.TopResponse, error)

ContainerTop shows process information from within a container.

func (*Client) ContainerUnpause

func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error

ContainerUnpause resumes the process execution within a container.

func (*Client) ContainerUpdate

func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.UpdateResponse, error)

ContainerUpdate updates the resources of a container.

func (*Client) ContainerWait

func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)

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

If this client's API version is before 1.30, "condition" is ignored and ContainerWait returns immediately with the two channels, as the server waits as if the condition were "not-running".

If this client's API version is at least 1.30, 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 (container.WaitConditionNextExit) before issuing a Client.ContainerStart request.

Example (WithTimeout)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

client, _ := NewClientWithOpts(FromEnv)
_, errC := client.ContainerWait(ctx, "container_id", "")
if err := <-errC; err != nil {
	log.Fatal(err)
}

func (*Client) ContainersPrune

func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)

ContainersPrune requests the daemon to delete unused data

func (*Client) CopyFromContainer

func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, container.PathStat, error)

CopyFromContainer 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) CopyToContainer

func (cli *Client) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options CopyToContainerOptions) error

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

func (*Client) DaemonHost

func (cli *Client) DaemonHost() string

DaemonHost returns the host address used by the client

func (*Client) DialHijack

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

DialHijack returns a hijacked connection with negotiated protocol proto.

func (*Client) Dialer

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

Dialer returns a dialer for a raw stream connection, with an HTTP/1.1 header, that can be used for proxying the daemon connection. It is used by "docker dial-stdio".

func (*Client) DiskUsage

func (cli *Client) DiskUsage(ctx context.Context, options DiskUsageOptions) (system.DiskUsage, error)

DiskUsage requests the current data usage from the daemon

func (*Client) DistributionInspect

func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error)

DistributionInspect returns the image digest with the full manifest.

func (*Client) Events

func (cli *Client) Events(ctx context.Context, options EventsListOptions) (<-chan events.Message, <-chan error)

Events returns a stream of events in the daemon. It's up to the caller to close the stream by cancelling the context. Once the stream has been completely read an io.EOF error is sent over the error channel. If an error is sent, all processing is stopped. It's up to the caller to reopen the stream in the event of an error by reinvoking this method.

func (*Client) HTTPClient

func (cli *Client) HTTPClient() *http.Client

HTTPClient returns a copy of the HTTP client bound to the server

func (*Client) ImageBuild

func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResponse, 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 (cli *Client) ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)

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

func (*Client) ImageHistory

func (cli *Client) ImageHistory(ctx context.Context, imageID string, historyOpts ...ImageHistoryOption) ([]image.HistoryResponseItem, error)

ImageHistory returns the changes in an image in history format.

func (*Client) ImageImport

func (cli *Client) ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (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 (cli *Client) ImageInspect(ctx context.Context, imageID string, inspectOpts ...ImageInspectOption) (image.InspectResponse, error)

ImageInspect returns the image information.

func (*Client) ImageList

func (cli *Client) ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error)

ImageList returns a list of images in the docker host.

Experimental: Set the image.ListOptions.Manifest option to include image.Summary.Manifests with information about image manifests. This is experimental and might change in the future without any backward compatibility.

func (*Client) ImageLoad

func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, loadOpts ...ImageLoadOption) (LoadResponse, 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 image.LoadResponse returned by this function.

Platform is an optional parameter that specifies the platform to load from the provided multi-platform image. Passing a platform only has an effect if the input image is a multi-platform image.

func (*Client) ImagePull

func (cli *Client) ImagePull(ctx context.Context, refStr string, options ImagePullOptions) (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.

func (*Client) ImagePush

func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePushOptions) (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. It's up to the caller to handle the io.ReadCloser and close it.

func (*Client) ImageRemove

func (cli *Client) ImageRemove(ctx context.Context, imageID string, options ImageRemoveOptions) ([]image.DeleteResponse, error)

ImageRemove removes an image from the docker host.

func (*Client) ImageSave

func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ...ImageSaveOption) (io.ReadCloser, error)

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

Platforms is an optional parameter that specifies the platforms to save from the image. Passing a platform only has an effect if the input image is a multi-platform image.

func (*Client) ImageSearch

func (cli *Client) ImageSearch(ctx context.Context, term string, options ImageSearchOptions) ([]registry.SearchResult, 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 (cli *Client) ImageTag(ctx context.Context, source, target string) error

ImageTag tags an image in the docker host

func (*Client) ImagesPrune

func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (image.PruneReport, error)

ImagesPrune requests the daemon to delete unused data

func (*Client) Info

func (cli *Client) Info(ctx context.Context) (system.Info, error)

Info returns information about the docker server.

func (*Client) NegotiateAPIVersion

func (cli *Client) NegotiateAPIVersion(ctx context.Context)

NegotiateAPIVersion queries the API and updates the version to match the API version. NegotiateAPIVersion downgrades the client's API version to match the APIVersion if the ping version is lower than the default version. If the API version reported by the server is higher than the maximum version supported by the client, it uses the client's maximum version.

If a manual override is in place, either through the "DOCKER_API_VERSION" (EnvOverrideAPIVersion) environment variable, or if the client is initialized with a fixed version (WithVersion), no negotiation is performed.

If the API server's ping response does not contain an API version, or if the client did not get a successful ping response, it assumes it is connected with an old daemon that does not support API version negotiation, in which case it downgrades to the latest version of the API before version negotiation was added (1.24).

func (*Client) NegotiateAPIVersionPing

func (cli *Client) NegotiateAPIVersionPing(pingResponse types.Ping)

NegotiateAPIVersionPing downgrades the client's API version to match the APIVersion in the ping response. If the API version in pingResponse is higher than the maximum version supported by the client, it uses the client's maximum version.

If a manual override is in place, either through the "DOCKER_API_VERSION" (EnvOverrideAPIVersion) environment variable, or if the client is initialized with a fixed version (WithVersion), no negotiation is performed.

If the API server's ping response does not contain an API version, we assume we are connected with an old daemon without API version negotiation support, and downgrade to the latest version of the API before version negotiation was added (1.24).

func (*Client) NetworkConnect

func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error

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

func (*Client) NetworkCreate

func (cli *Client) NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error)

NetworkCreate creates a new network in the docker host.

func (*Client) NetworkDisconnect

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

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

func (*Client) NetworkInspect

func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options NetworkInspectOptions) (network.Inspect, error)

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

func (*Client) NetworkInspectWithRaw

func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options NetworkInspectOptions) (network.Inspect, []byte, error)

NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.

func (*Client) NetworkList

func (cli *Client) NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)

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

func (*Client) NetworkRemove

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

NetworkRemove removes an existent network from the docker host.

func (*Client) NetworksPrune

func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error)

NetworksPrune requests the daemon to delete unused networks

func (*Client) NewVersionError

func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature string) error

NewVersionError returns an error if the APIVersion required is less than the current supported version.

It performs API-version negotiation if the Client is configured with this option, otherwise it assumes the latest API version is used.

func (*Client) NodeInspectWithRaw

func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)

NodeInspectWithRaw returns the node information.

func (*Client) NodeList

func (cli *Client) NodeList(ctx context.Context, options NodeListOptions) ([]swarm.Node, error)

NodeList returns the list of nodes.

func (*Client) NodeRemove

func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) error

NodeRemove removes a Node.

func (*Client) NodeUpdate

func (cli *Client) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error

NodeUpdate updates a Node.

func (*Client) Ping

func (cli *Client) Ping(ctx context.Context) (types.Ping, error)

Ping pings the server and returns the value of the "Docker-Experimental", "Builder-Version", "OS-Type" & "API-Version" headers. It attempts to use a HEAD request on the endpoint, but falls back to GET if HEAD is not supported by the daemon. It ignores internal server errors returned by the API, which may be returned if the daemon is in an unhealthy state, but returns errors for other non-success status codes, failing to connect to the API, or failing to parse the API response.

func (*Client) PluginCreate

func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions PluginCreateOptions) error

PluginCreate creates a plugin

func (*Client) PluginDisable

func (cli *Client) PluginDisable(ctx context.Context, name string, options PluginDisableOptions) error

PluginDisable disables a plugin

func (*Client) PluginEnable

func (cli *Client) PluginEnable(ctx context.Context, name string, options PluginEnableOptions) error

PluginEnable enables a plugin

func (*Client) PluginInspectWithRaw

func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*plugin.Plugin, []byte, error)

PluginInspectWithRaw inspects an existing plugin

func (*Client) PluginInstall

func (cli *Client) PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (_ io.ReadCloser, retErr error)

PluginInstall installs a plugin

func (*Client) PluginList

func (cli *Client) PluginList(ctx context.Context, filter filters.Args) (plugin.ListResponse, error)

PluginList returns the installed plugins

func (*Client) PluginPush

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

PluginPush pushes a plugin to a registry

func (*Client) PluginRemove

func (cli *Client) PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) error

PluginRemove removes a plugin

func (*Client) PluginSet

func (cli *Client) PluginSet(ctx context.Context, name string, args []string) error

PluginSet modifies settings for an existing plugin

func (*Client) PluginUpgrade

func (cli *Client) PluginUpgrade(ctx context.Context, name string, options PluginInstallOptions) (io.ReadCloser, error)

PluginUpgrade upgrades a plugin

func (*Client) RegistryLogin

func (cli *Client) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)

RegistryLogin authenticates the docker server with a given docker registry. It returns unauthorizedError when the authentication fails.

func (*Client) SecretCreate

func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error)

SecretCreate creates a new secret.

func (*Client) SecretInspectWithRaw

func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error)

SecretInspectWithRaw returns the secret information with raw data

func (*Client) SecretList

func (cli *Client) SecretList(ctx context.Context, options SecretListOptions) ([]swarm.Secret, error)

SecretList returns the list of secrets.

func (*Client) SecretRemove

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

SecretRemove removes a secret.

func (*Client) SecretUpdate

func (cli *Client) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error

SecretUpdate attempts to update a secret.

func (*Client) ServerVersion

func (cli *Client) ServerVersion(ctx context.Context) (types.Version, error)

ServerVersion returns information of the docker client and server host.

func (*Client) ServiceCreate

func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options ServiceCreateOptions) (swarm.ServiceCreateResponse, error)

ServiceCreate creates a new service.

func (*Client) ServiceInspectWithRaw

func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts ServiceInspectOptions) (swarm.Service, []byte, error)

ServiceInspectWithRaw returns the service information and the raw data.

func (*Client) ServiceList

func (cli *Client) ServiceList(ctx context.Context, options ServiceListOptions) ([]swarm.Service, error)

ServiceList returns the list of services.

func (*Client) ServiceLogs

func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options ContainerLogsOptions) (io.ReadCloser, error)

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

Example (WithTimeout)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

client, _ := NewClientWithOpts(FromEnv)
reader, err := client.ServiceLogs(ctx, "service_id", ContainerLogsOptions{})
if err != nil {
	log.Fatal(err)
}

_, err = io.Copy(os.Stdout, reader)
if err != nil && !errors.Is(err, io.EOF) {
	log.Fatal(err)
}

func (*Client) ServiceRemove

func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error

ServiceRemove kills and removes a service.

func (*Client) ServiceUpdate

func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)

ServiceUpdate updates a Service. The version number is required to avoid conflicting writes. It must be the value as set *before* the update. You can find this value in the swarm.Service.Meta field, which can be found using Client.ServiceInspectWithRaw.

func (*Client) SwarmGetUnlockKey

func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error)

SwarmGetUnlockKey retrieves the swarm's unlock key.

func (*Client) SwarmInit

func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)

SwarmInit initializes the swarm.

func (*Client) SwarmInspect

func (cli *Client) SwarmInspect(ctx context.Context) (swarm.Swarm, error)

SwarmInspect inspects the swarm.

func (*Client) SwarmJoin

func (cli *Client) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error

SwarmJoin joins the swarm.

func (*Client) SwarmLeave

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

SwarmLeave leaves the swarm.

func (*Client) SwarmUnlock

func (cli *Client) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error

SwarmUnlock unlocks locked swarm.

func (*Client) SwarmUpdate

func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) error

SwarmUpdate updates the swarm.

func (*Client) TaskInspectWithRaw

func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)

TaskInspectWithRaw returns the task information and its raw representation.

func (*Client) TaskList

func (cli *Client) TaskList(ctx context.Context, options TaskListOptions) ([]swarm.Task, error)

TaskList returns the list of tasks.

func (*Client) TaskLogs

func (cli *Client) TaskLogs(ctx context.Context, taskID string, options ContainerLogsOptions) (io.ReadCloser, error)

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

func (*Client) VolumeCreate

func (cli *Client) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)

VolumeCreate creates a volume in the docker host.

func (*Client) VolumeInspect

func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)

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

func (*Client) VolumeInspectWithRaw

func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)

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

func (*Client) VolumeList

func (cli *Client) VolumeList(ctx context.Context, options VolumeListOptions) (volume.ListResponse, error)

VolumeList returns the volumes configured in the docker host.

func (*Client) VolumeRemove

func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error

VolumeRemove removes a volume from the docker host.

func (*Client) VolumeUpdate

func (cli *Client) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error

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

func (*Client) VolumesPrune

func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (volume.PruneReport, error)

VolumesPrune requests the daemon to delete unused data

type CloseWriter

type CloseWriter interface {
	CloseWrite() error
}

CloseWriter is an interface that implements structs that close input streams to prevent from writing.

type ConfigAPIClient

type ConfigAPIClient interface {
	ConfigList(ctx context.Context, options ConfigListOptions) ([]swarm.Config, error)
	ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)
	ConfigRemove(ctx context.Context, id string) error
	ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
	ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
}

ConfigAPIClient defines API client methods for configs

type ConfigListOptions

type ConfigListOptions struct {
	Filters filters.Args
}

ConfigListOptions holds parameters to list configs

type ContainerAPIClient

type ContainerAPIClient interface {
	ContainerAttach(ctx context.Context, container string, options ContainerAttachOptions) (HijackedResponse, error)
	ContainerCommit(ctx context.Context, container string, options ContainerCommitOptions) (container.CommitResponse, error)
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
	ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error)
	ContainerExecAttach(ctx context.Context, execID string, options container.ExecAttachOptions) (HijackedResponse, error)
	ContainerExecCreate(ctx context.Context, container string, options container.ExecOptions) (container.ExecCreateResponse, error)
	ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
	ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) error
	ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error
	ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
	ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error)
	ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (container.InspectResponse, []byte, error)
	ContainerKill(ctx context.Context, container, signal string) error
	ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error)
	ContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (io.ReadCloser, error)
	ContainerPause(ctx context.Context, container string) error
	ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) error
	ContainerRename(ctx context.Context, container, newContainerName string) error
	ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) error
	ContainerRestart(ctx context.Context, container string, options ContainerStopOptions) error
	ContainerStatPath(ctx context.Context, container, path string) (container.PathStat, error)
	ContainerStats(ctx context.Context, container string, stream bool) (StatsResponseReader, error)
	ContainerStatsOneShot(ctx context.Context, container string) (StatsResponseReader, error)
	ContainerStart(ctx context.Context, container string, options ContainerStartOptions) error
	ContainerStop(ctx context.Context, container string, options ContainerStopOptions) error
	ContainerTop(ctx context.Context, container string, arguments []string) (container.TopResponse, error)
	ContainerUnpause(ctx context.Context, container string) error
	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.UpdateResponse, error)
	ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, container.PathStat, error)
	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options CopyToContainerOptions) error
	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)
}

ContainerAPIClient defines API client methods for the containers

type ContainerAttachOptions

type ContainerAttachOptions struct {
	Stream     bool
	Stdin      bool
	Stdout     bool
	Stderr     bool
	DetachKeys string
	Logs       bool
}

ContainerAttachOptions holds parameters to attach to a container.

type ContainerCommitOptions

type ContainerCommitOptions struct {
	Reference string
	Comment   string
	Author    string
	Changes   []string
	Pause     bool
	Config    *container.Config
}

ContainerCommitOptions holds parameters to commit changes into a container.

type ContainerListOptions

type ContainerListOptions struct {
	Size    bool
	All     bool
	Latest  bool
	Since   string
	Before  string
	Limit   int
	Filters filters.Args
}

ContainerListOptions holds parameters to list containers with.

type ContainerLogsOptions

type ContainerLogsOptions struct {
	ShowStdout bool
	ShowStderr bool
	Since      string
	Until      string
	Timestamps bool
	Follow     bool
	Tail       string
	Details    bool
}

ContainerLogsOptions holds parameters to filter logs with.

type ContainerRemoveOptions

type ContainerRemoveOptions struct {
	RemoveVolumes bool
	RemoveLinks   bool
	Force         bool
}

ContainerRemoveOptions holds parameters to remove containers.

type ContainerResizeOptions

type ContainerResizeOptions struct {
	Height uint
	Width  uint
}

ContainerResizeOptions holds parameters to resize a TTY. It can be used to resize container TTYs and exec process TTYs too.

type ContainerStartOptions

type ContainerStartOptions struct {
	CheckpointID  string
	CheckpointDir string
}

ContainerStartOptions holds parameters to start containers.

type ContainerStopOptions

type ContainerStopOptions struct {
	// Signal (optional) is the signal to send to the container to (gracefully)
	// stop it before forcibly terminating the container with SIGKILL after the
	// timeout expires. If not value is set, the default (SIGTERM) is used.
	Signal string `json:",omitempty"`

	// Timeout (optional) is the timeout (in seconds) to wait for the container
	// to stop gracefully before forcibly terminating it with SIGKILL.
	//
	// - Use nil to use the default timeout (10 seconds).
	// - Use '-1' to wait indefinitely.
	// - Use '0' to not wait for the container to exit gracefully, and
	//   immediately proceeds to forcibly terminating the container.
	// - Other positive values are used as timeout (in seconds).
	Timeout *int `json:",omitempty"`
}

ContainerStopOptions holds the options to stop or restart a container.

type CopyToContainerOptions

type CopyToContainerOptions struct {
	AllowOverwriteDirWithFile bool
	CopyUIDGID                bool
}

CopyToContainerOptions holds information about files to copy into a container

type DiskUsageOptions

type DiskUsageOptions struct {
	// Types specifies what object types to include in the response. If empty,
	// all object types are returned.
	Types []system.DiskUsageObject
}

DiskUsageOptions holds parameters for system disk usage query.

type DistributionAPIClient

type DistributionAPIClient interface {
	DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
}

DistributionAPIClient defines API client methods for the registry

type EventsListOptions

type EventsListOptions struct {
	Since   string
	Until   string
	Filters filters.Args
}

EventsListOptions holds parameters to filter events with.

type HijackDialer

type HijackDialer interface {
	DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error)
}

HijackDialer defines methods for a hijack dialer.

type HijackedResponse

type HijackedResponse struct {
	Conn   net.Conn
	Reader *bufio.Reader
	// contains filtered or unexported fields
}

HijackedResponse holds connection information for a hijacked request.

func NewHijackedResponse

func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse

NewHijackedResponse initializes a HijackedResponse type.

func (*HijackedResponse) Close

func (h *HijackedResponse) Close()

Close closes the hijacked connection and reader.

func (*HijackedResponse) CloseWrite

func (h *HijackedResponse) CloseWrite() error

CloseWrite closes a readWriter for writing.

func (*HijackedResponse) MediaType

func (h *HijackedResponse) MediaType() (string, bool)

MediaType let client know if HijackedResponse hold a raw or multiplexed stream. returns false if HTTP Content-Type is not relevant, and the container must be inspected.

type ImageAPIClient

type ImageAPIClient interface {
	ImageBuild(ctx context.Context, context io.Reader, options ImageBuildOptions) (ImageBuildResponse, error)
	BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (*build.CachePruneReport, error)
	BuildCancel(ctx context.Context, id string) error
	ImageCreate(ctx context.Context, parentReference string, options ImageCreateOptions) (io.ReadCloser, error)
	ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (io.ReadCloser, error)

	ImageList(ctx context.Context, options ImageListOptions) ([]image.Summary, error)
	ImagePull(ctx context.Context, ref string, options ImagePullOptions) (io.ReadCloser, error)
	ImagePush(ctx context.Context, ref string, options ImagePushOptions) (io.ReadCloser, error)
	ImageRemove(ctx context.Context, image string, options ImageRemoveOptions) ([]image.DeleteResponse, error)
	ImageSearch(ctx context.Context, term string, options ImageSearchOptions) ([]registry.SearchResult, error)
	ImageTag(ctx context.Context, image, ref string) error
	ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error)

	ImageInspect(ctx context.Context, image string, _ ...ImageInspectOption) (image.InspectResponse, error)
	ImageHistory(ctx context.Context, image string, _ ...ImageHistoryOption) ([]image.HistoryResponseItem, error)
	ImageLoad(ctx context.Context, input io.Reader, _ ...ImageLoadOption) (LoadResponse, error)
	ImageSave(ctx context.Context, images []string, _ ...ImageSaveOption) (io.ReadCloser, error)
}

ImageAPIClient defines API client methods for the images

type ImageBuildOptions

type ImageBuildOptions struct {
	Tags           []string
	SuppressOutput bool
	RemoteContext  string
	NoCache        bool
	Remove         bool
	ForceRemove    bool
	PullParent     bool
	Isolation      container.Isolation
	CPUSetCPUs     string
	CPUSetMems     string
	CPUShares      int64
	CPUQuota       int64
	CPUPeriod      int64
	Memory         int64
	MemorySwap     int64
	CgroupParent   string
	NetworkMode    string
	ShmSize        int64
	Dockerfile     string
	Ulimits        []*container.Ulimit
	// BuildArgs needs to be a *string instead of just a string so that
	// we can tell the difference between "" (empty string) and no value
	// at all (nil). See the parsing of buildArgs in
	// api/server/router/build/build_routes.go for even more info.
	BuildArgs   map[string]*string
	AuthConfigs map[string]registry.AuthConfig
	Context     io.Reader
	Labels      map[string]string
	// squash the resulting image's layers to the parent
	// preserves the original image and creates a new one from the parent with all
	// the changes applied to a single layer
	Squash bool
	// CacheFrom specifies images that are used for matching cache. Images
	// specified here do not need to have a valid parent chain to match cache.
	CacheFrom   []string
	SecurityOpt []string
	ExtraHosts  []string // List of extra hosts
	Target      string
	SessionID   string
	Platform    string
	// Version specifies the version of the underlying builder to use
	Version build.BuilderVersion
	// BuildID is an optional identifier that can be passed together with the
	// build request. The same identifier can be used to gracefully cancel the
	// build with the cancel request.
	BuildID string
	// Outputs defines configurations for exporting build results. Only supported
	// in BuildKit mode
	Outputs []ImageBuildOutput
}

ImageBuildOptions holds the information necessary to build images.

type ImageBuildOutput

type ImageBuildOutput struct {
	Type  string
	Attrs map[string]string
}

ImageBuildOutput defines configuration for exporting a build result

type ImageBuildResponse

type ImageBuildResponse struct {
	Body   io.ReadCloser
	OSType string
}

ImageBuildResponse holds information returned by a server after building an image.

type ImageCreateOptions

type ImageCreateOptions struct {
	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
}

ImageCreateOptions holds information to create images.

type ImageHistoryOption

type ImageHistoryOption interface {
	Apply(*imageHistoryOpts) error
}

ImageHistoryOption is a type representing functional options for the image history operation.

func ImageHistoryWithPlatform

func ImageHistoryWithPlatform(platform ocispec.Platform) ImageHistoryOption

ImageHistoryWithPlatform sets the platform for the image history operation.

type ImageImportOptions

type ImageImportOptions struct {
	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
	Message  string   // Message is the message to tag the image with
	Changes  []string // Changes are the raw changes to apply to this image
	Platform string   // Platform is the target platform of the image
}

ImageImportOptions holds information to import images from the client host.

type ImageImportSource

type ImageImportSource struct {
	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
}

ImageImportSource holds source information for ImageImport

type ImageInspectOption

type ImageInspectOption interface {
	Apply(*imageInspectOpts) error
}

ImageInspectOption is a type representing functional options for the image inspect operation.

func ImageInspectWithAPIOpts

func ImageInspectWithAPIOpts(opts ImageInspectOptions) ImageInspectOption

ImageInspectWithAPIOpts sets the API options for the image inspect operation.

func ImageInspectWithManifests

func ImageInspectWithManifests(manifests bool) ImageInspectOption

ImageInspectWithManifests sets manifests API option for the image inspect operation. This option is only available for API version 1.48 and up. With this option set, the image inspect operation response includes the image.InspectResponse.Manifests field if the server is multi-platform capable.

func ImageInspectWithPlatform

func ImageInspectWithPlatform(platform *ocispec.Platform) ImageInspectOption

ImageInspectWithPlatform sets platform API option for the image inspect operation. This option is only available for API version 1.49 and up. With this option set, the image inspect operation returns information for the specified platform variant of the multi-platform image.

func ImageInspectWithRawResponse

func ImageInspectWithRawResponse(raw *bytes.Buffer) ImageInspectOption

ImageInspectWithRawResponse instructs the client to additionally store the raw inspect response in the provided buffer.

type ImageInspectOptions

type ImageInspectOptions struct {
	// Manifests returns the image manifests.
	Manifests bool

	// Platform selects the specific platform of a multi-platform image to inspect.
	//
	// This option is only available for API version 1.49 and up.
	Platform *ocispec.Platform
}

type ImageListOptions

type ImageListOptions struct {
	// All controls whether all images in the graph are filtered, or just
	// the heads.
	All bool

	// Filters is a JSON-encoded set of filter arguments.
	Filters filters.Args

	// SharedSize indicates whether the shared size of images should be computed.
	SharedSize bool

	// ContainerCount indicates whether container count should be computed.
	//
	// Deprecated: This field has been unused and is no longer required and will be removed in a future version.
	ContainerCount bool

	// Manifests indicates whether the image manifests should be returned.
	Manifests bool
}

ImageListOptions holds parameters to list images with.

type ImageLoadOption

type ImageLoadOption interface {
	Apply(*imageLoadOpts) error
}

ImageLoadOption is a type representing functional options for the image load operation.

func ImageLoadWithPlatforms

func ImageLoadWithPlatforms(platforms ...ocispec.Platform) ImageLoadOption

ImageLoadWithPlatforms sets the platforms to be loaded from the image.

func ImageLoadWithQuiet

func ImageLoadWithQuiet(quiet bool) ImageLoadOption

ImageLoadWithQuiet sets the quiet option for the image load operation.

type ImagePullOptions

type ImagePullOptions struct {
	All          bool
	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry

	// PrivilegeFunc is a function that clients can supply to retry operations
	// after getting an authorization error. This function returns the registry
	// authentication header value in base64 encoded format, or an error if the
	// privilege request fails.
	//
	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
	PrivilegeFunc func(context.Context) (string, error)
	Platform      string
}

ImagePullOptions holds information to pull images.

type ImagePushOptions

type ImagePushOptions struct {
	All          bool
	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry

	// PrivilegeFunc is a function that clients can supply to retry operations
	// after getting an authorization error. This function returns the registry
	// authentication header value in base64 encoded format, or an error if the
	// privilege request fails.
	//
	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
	PrivilegeFunc func(context.Context) (string, error)

	// Platform is an optional field that selects a specific platform to push
	// when the image is a multi-platform image.
	// Using this will only push a single platform-specific manifest.
	Platform *ocispec.Platform `json:",omitempty"`
}

ImagePushOptions holds information to push images.

type ImageRemoveOptions

type ImageRemoveOptions struct {
	Platforms     []ocispec.Platform
	Force         bool
	PruneChildren bool
}

ImageRemoveOptions holds parameters to remove images.

type ImageSaveOption

type ImageSaveOption interface {
	Apply(*imageSaveOpts) error
}

func ImageSaveWithPlatforms

func ImageSaveWithPlatforms(platforms ...ocispec.Platform) ImageSaveOption

ImageSaveWithPlatforms sets the platforms to be saved from the image.

type ImageSearchOptions

type ImageSearchOptions struct {
	RegistryAuth string

	// PrivilegeFunc is a function that clients can supply to retry operations
	// after getting an authorization error. This function returns the registry
	// authentication header value in base64 encoded format, or an error if the
	// privilege request fails.
	//
	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
	PrivilegeFunc func(context.Context) (string, error)
	Filters       filters.Args
	Limit         int
}

ImageSearchOptions holds parameters to search images with.

type LoadResponse

type LoadResponse struct {
	// Body must be closed to avoid a resource leak
	Body io.ReadCloser
	JSON bool
}

LoadResponse returns information to the client about a load process.

TODO(thaJeztah): remove this type, and just use an io.ReadCloser

This type was added in https://github.com/moby/moby/pull/18878, related to https://github.com/moby/moby/issues/19177;

Make docker load to output json when the response content type is json Swarm hijacks the response from docker load and returns JSON rather than plain text like the Engine does. This makes the API library to return information to figure that out.

However the "load" endpoint unconditionally returns JSON; https://github.com/moby/moby/blob/7b9d2ef6e5518a3d3f3cc418459f8df786cfbbd1/api/server/router/image/image_routes.go#L248-L255

PR https://github.com/moby/moby/pull/21959 made the response-type depend on whether "quiet" was set, but this logic got changed in a follow-up https://github.com/moby/moby/pull/25557, which made the JSON response-type unconditionally, but the output produced depend on whether"quiet" was set.

We should deprecated the "quiet" option, as it's really a client responsibility.

type NetworkAPIClient

type NetworkAPIClient interface {
	NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
	NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error)
	NetworkDisconnect(ctx context.Context, network, container string, force bool) error
	NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, error)
	NetworkInspectWithRaw(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, []byte, error)
	NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)
	NetworkRemove(ctx context.Context, network string) error
	NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
}

NetworkAPIClient defines API client methods for the networks

type NetworkConnectOptions

type NetworkConnectOptions struct {
	Container      string
	EndpointConfig *network.EndpointSettings `json:",omitempty"`
}

NetworkConnectOptions represents the data to be used to connect a container to the network.

type NetworkCreateOptions

type NetworkCreateOptions struct {
	Driver     string                   // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
	Scope      string                   // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
	EnableIPv4 *bool                    // EnableIPv4 represents whether to enable IPv4.
	EnableIPv6 *bool                    // EnableIPv6 represents whether to enable IPv6.
	IPAM       *network.IPAM            // IPAM is the network's IP Address Management.
	Internal   bool                     // Internal represents if the network is used internal only.
	Attachable bool                     // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
	Ingress    bool                     // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
	ConfigOnly bool                     // ConfigOnly creates a config-only network. Config-only networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
	ConfigFrom *network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
	Options    map[string]string        // Options specifies the network-specific options to use for when creating the network.
	Labels     map[string]string        // Labels holds metadata specific to the network being created.
}

NetworkCreateOptions holds options to create a network.

type NetworkDisconnectOptions

type NetworkDisconnectOptions struct {
	Container string
	Force     bool
}

NetworkDisconnectOptions represents the data to be used to disconnect a container from the network.

type NetworkInspectOptions

type NetworkInspectOptions struct {
	Scope   string
	Verbose bool
}

NetworkInspectOptions holds parameters to inspect network.

type NetworkListOptions

type NetworkListOptions struct {
	Filters filters.Args
}

NetworkListOptions holds parameters to filter the list of networks with.

type NodeAPIClient

type NodeAPIClient interface {
	NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
	NodeList(ctx context.Context, options NodeListOptions) ([]swarm.Node, error)
	NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) error
	NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
}

NodeAPIClient defines API client methods for the nodes

type NodeListOptions

type NodeListOptions struct {
	Filters filters.Args
}

NodeListOptions holds parameters to list nodes with.

type NodeRemoveOptions

type NodeRemoveOptions struct {
	Force bool
}

NodeRemoveOptions holds parameters to remove nodes with.

type Opt

type Opt func(*clientConfig) error

Opt is a configuration option to initialize a Client.

func WithAPIVersionNegotiation

func WithAPIVersionNegotiation() Opt

WithAPIVersionNegotiation enables automatic API version negotiation for the client. With this option enabled, the client automatically negotiates the API version to use when making requests. API version negotiation is performed on the first request; subsequent requests do not re-negotiate.

func WithDialContext

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

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 a http.Transport configured.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Opt

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

func WithHTTPHeaders

func WithHTTPHeaders(headers map[string]string) Opt

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) Opt

WithHost overrides the client host with the specified one.

func WithHostFromEnv

func WithHostFromEnv() Opt

WithHostFromEnv overrides the client host with the host specified in the DOCKER_HOST (EnvOverrideHost) 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) Opt

WithScheme overrides the client scheme with the specified one.

func WithTLSClientConfig

func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt

WithTLSClientConfig applies a TLS config to the client transport.

func WithTLSClientConfigFromEnv

func WithTLSClientConfigFromEnv() Opt

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

WithTLSClientConfigFromEnv uses the following environment variables:

  • DOCKER_CERT_PATH (EnvOverrideCertPath) to specify the directory from which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem").
  • DOCKER_TLS_VERIFY (EnvTLSVerify) to enable or disable TLS verification (off by default).

func WithTimeout

func WithTimeout(timeout time.Duration) Opt

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

func WithTraceOptions

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

WithTraceOptions sets tracing span options for the client.

func WithTraceProvider

func WithTraceProvider(provider trace.TracerProvider) Opt

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

func WithUserAgent

func WithUserAgent(ua string) Opt

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.

func WithVersion

func WithVersion(version string) Opt

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

WithVersion does not validate if the client supports the given version, and callers should verify if the version is in the correct format and lower than the maximum supported version as defined by MaxAPIVersion.

func WithVersionFromEnv

func WithVersionFromEnv() Opt

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

WithVersion does not validate if the client supports the given version, and callers should verify if the version is in the correct format and lower than the maximum supported version as defined by MaxAPIVersion.

type PluginAPIClient

type PluginAPIClient interface {
	PluginList(ctx context.Context, filter filters.Args) (plugin.ListResponse, error)
	PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) error
	PluginEnable(ctx context.Context, name string, options PluginEnableOptions) error
	PluginDisable(ctx context.Context, name string, options PluginDisableOptions) error
	PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (io.ReadCloser, error)
	PluginUpgrade(ctx context.Context, name string, options PluginInstallOptions) (io.ReadCloser, error)
	PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
	PluginSet(ctx context.Context, name string, args []string) error
	PluginInspectWithRaw(ctx context.Context, name string) (*plugin.Plugin, []byte, error)
	PluginCreate(ctx context.Context, createContext io.Reader, options PluginCreateOptions) error
}

PluginAPIClient defines API client methods for the plugins

type PluginCreateOptions

type PluginCreateOptions struct {
	RepoName string
}

PluginCreateOptions hold all options to plugin create.

type PluginDisableOptions

type PluginDisableOptions struct {
	Force bool
}

PluginDisableOptions holds parameters to disable plugins.

type PluginEnableOptions

type PluginEnableOptions struct {
	Timeout int
}

PluginEnableOptions holds parameters to enable plugins.

type PluginInstallOptions

type PluginInstallOptions struct {
	Disabled             bool
	AcceptAllPermissions bool
	RegistryAuth         string // RegistryAuth is the base64 encoded credentials for the registry
	RemoteRef            string // RemoteRef is the plugin name on the registry

	// PrivilegeFunc is a function that clients can supply to retry operations
	// after getting an authorization error. This function returns the registry
	// authentication header value in base64 encoded format, or an error if the
	// privilege request fails.
	//
	// For details, refer to [github.com/moby/moby/api/types/registry.RequestAuthConfig].
	PrivilegeFunc         func(context.Context) (string, error)
	AcceptPermissionsFunc func(context.Context, plugin.Privileges) (bool, error)
	Args                  []string
}

PluginInstallOptions holds parameters to install a plugin.

type PluginRemoveOptions

type PluginRemoveOptions struct {
	Force bool
}

PluginRemoveOptions holds parameters to remove plugins.

type SecretAPIClient

type SecretAPIClient interface {
	SecretList(ctx context.Context, options SecretListOptions) ([]swarm.Secret, error)
	SecretCreate(ctx context.Context, secret swarm.SecretSpec) (swarm.SecretCreateResponse, error)
	SecretRemove(ctx context.Context, id string) error
	SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
	SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
}

SecretAPIClient defines API client methods for secrets

type SecretListOptions

type SecretListOptions struct {
	Filters filters.Args
}

SecretListOptions holds parameters to list secrets

type ServiceAPIClient

type ServiceAPIClient interface {
	ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
	ServiceInspectWithRaw(ctx context.Context, serviceID string, options ServiceInspectOptions) (swarm.Service, []byte, error)
	ServiceList(ctx context.Context, options ServiceListOptions) ([]swarm.Service, error)
	ServiceRemove(ctx context.Context, serviceID string) error
	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
	ServiceLogs(ctx context.Context, serviceID string, options ContainerLogsOptions) (io.ReadCloser, error)
	TaskLogs(ctx context.Context, taskID string, options ContainerLogsOptions) (io.ReadCloser, error)
	TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
	TaskList(ctx context.Context, options TaskListOptions) ([]swarm.Task, error)
}

ServiceAPIClient defines API client methods for the services

type ServiceCreateOptions

type ServiceCreateOptions struct {
	// EncodedRegistryAuth is the encoded registry authorization credentials to
	// use when updating the service.
	//
	// This field follows the format of the X-Registry-Auth header.
	EncodedRegistryAuth string

	// QueryRegistry indicates whether the service update requires
	// contacting a registry. A registry may be contacted to retrieve
	// the image digest and manifest, which in turn can be used to update
	// platform or other information about the service.
	QueryRegistry bool
}

ServiceCreateOptions contains the options to use when creating a service.

type ServiceInspectOptions

type ServiceInspectOptions struct {
	InsertDefaults bool
}

ServiceInspectOptions holds parameters related to the "service inspect" operation.

type ServiceListOptions

type ServiceListOptions struct {
	Filters filters.Args

	// Status indicates whether the server should include the service task
	// count of running and desired tasks.
	Status bool
}

ServiceListOptions holds parameters to list services with.

type ServiceUpdateOptions

type ServiceUpdateOptions struct {
	// EncodedRegistryAuth is the encoded registry authorization credentials to
	// use when updating the service.
	//
	// This field follows the format of the X-Registry-Auth header.
	EncodedRegistryAuth string

	// RegistryAuthFrom specifies where to find the registry authorization
	// credentials if they are not given in EncodedRegistryAuth. Valid
	// values are "spec" and "previous-spec".
	RegistryAuthFrom string

	// Rollback indicates whether a server-side rollback should be
	// performed. When this is set, the provided spec will be ignored.
	// The valid values are "previous" and "none". An empty value is the
	// same as "none".
	Rollback string

	// QueryRegistry indicates whether the service update requires
	// contacting a registry. A registry may be contacted to retrieve
	// the image digest and manifest, which in turn can be used to update
	// platform or other information about the service.
	QueryRegistry bool
}

ServiceUpdateOptions contains the options to be used for updating services.

type StatsResponseReader

type StatsResponseReader struct {
	Body   io.ReadCloser `json:"body"`
	OSType string        `json:"ostype"`
}

StatsResponseReader wraps an io.ReadCloser to read (a stream of) stats for a container, as produced by the GET "/stats" endpoint.

The OSType field is set to the server's platform to allow platform-specific handling of the response.

TODO(thaJeztah): remove this wrapper, and make OSType part of github.com/moby/moby/api/types/container.StatsResponse.

type SwarmAPIClient

type SwarmAPIClient interface {
	SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
	SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
	SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error)
	SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
	SwarmLeave(ctx context.Context, force bool) error
	SwarmInspect(ctx context.Context) (swarm.Swarm, error)
	SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) error
}

SwarmAPIClient defines API client methods for the swarm

type SwarmManagementAPIClient

type SwarmManagementAPIClient interface {
	SwarmAPIClient
	NodeAPIClient
	ServiceAPIClient
	SecretAPIClient
	ConfigAPIClient
}

SwarmManagementAPIClient defines all methods for managing Swarm-specific objects.

type SwarmUpdateFlags

type SwarmUpdateFlags struct {
	RotateWorkerToken      bool
	RotateManagerToken     bool
	RotateManagerUnlockKey bool
}

SwarmUpdateFlags contains flags for SwarmUpdate.

type SystemAPIClient

type SystemAPIClient interface {
	Events(ctx context.Context, options EventsListOptions) (<-chan events.Message, <-chan error)
	Info(ctx context.Context) (system.Info, error)
	RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
	DiskUsage(ctx context.Context, options DiskUsageOptions) (system.DiskUsage, error)
	Ping(ctx context.Context) (types.Ping, error)
}

SystemAPIClient defines API client methods for the system

type TaskListOptions

type TaskListOptions struct {
	Filters filters.Args
}

TaskListOptions holds parameters to list tasks with.

type VolumeAPIClient

type VolumeAPIClient interface {
	VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
	VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
	VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
	VolumeList(ctx context.Context, options VolumeListOptions) (volume.ListResponse, error)
	VolumeRemove(ctx context.Context, volumeID string, force bool) error
	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error)
	VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error
}

VolumeAPIClient defines API client methods for the volumes

type VolumeListOptions

type VolumeListOptions struct {
	Filters filters.Args
}

VolumeListOptions holds parameters to list volumes.

Source Files

Directories

Path Synopsis
internal
pkg
stringid
Package stringid provides helper functions for dealing with string identifiers.
Package stringid provides helper functions for dealing with string identifiers.

Jump to

Keyboard shortcuts

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