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 New and calling methods on it. The client can be configured from environment variables by passing the FromEnv option, and the WithAPIVersionNegotiation option to allow downgrading the API version used when connecting with an older daemon version. Other options cen be configured manually by passing any of the available Opt options.
For example, to list running containers (the equivalent of "docker ps"):
package main
import (
"context"
"fmt"
"log"
"github.com/moby/moby/client"
)
func main() {
// Create a new client that handles common environment variables
// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
// API-version negotiation to allow downgrading the API version
// when connecting with an older daemon version.
apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
log.Fatal(err)
}
// List all containers (both stopped and running).
result, err := apiClient.ContainerList(context.Background(), client.ContainerListOptions{
All: true,
})
if err != nil {
log.Fatal(err)
}
// Print each container's ID, status and the image it was created from.
fmt.Printf("%s %-22s %s\n", "ID", "STATUS", "IMAGE")
for _, ctr := range result.Items {
fmt.Printf("%s %-22s %s\n", ctr.ID, ctr.Status, ctr.Image)
}
}
Index ¶
- Constants
- Variables
- func CheckRedirect(_ *http.Request, via []*http.Request) error
- func FromEnv(c *clientConfig) error
- func IsErrConnectionFailed(err error) bool
- func ParseHostURL(host string) (*url.URL, error)
- type APIClient
- type BuildCacheDiskUsage
- type BuildCachePruneOptions
- type BuildCachePruneResult
- type BuildCancelOptions
- type BuildCancelResult
- type CheckpointAPIClient
- type CheckpointCreateOptions
- type CheckpointCreateResult
- type CheckpointListOptions
- type CheckpointListResult
- type CheckpointRemoveOptions
- type CheckpointRemoveResult
- type Client
- func (cli *Client) BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (BuildCachePruneResult, error)
- func (cli *Client) BuildCancel(ctx context.Context, id string, _ BuildCancelOptions) (BuildCancelResult, error)
- func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) (CheckpointCreateResult, error)
- func (cli *Client) CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
- func (cli *Client) CheckpointRemove(ctx context.Context, containerID string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error)
- func (cli *Client) ClientVersion() string
- func (cli *Client) Close() error
- func (cli *Client) ConfigCreate(ctx context.Context, options ConfigCreateOptions) (ConfigCreateResult, error)
- func (cli *Client) ConfigInspect(ctx context.Context, id string, options ConfigInspectOptions) (ConfigInspectResult, error)
- func (cli *Client) ConfigList(ctx context.Context, options ConfigListOptions) (ConfigListResult, error)
- func (cli *Client) ConfigRemove(ctx context.Context, id string, options ConfigRemoveOptions) (ConfigRemoveResult, error)
- func (cli *Client) ConfigUpdate(ctx context.Context, id string, options ConfigUpdateOptions) (ConfigUpdateResult, error)
- func (cli *Client) ContainerAttach(ctx context.Context, containerID string, options ContainerAttachOptions) (ContainerAttachResult, error)
- func (cli *Client) ContainerCommit(ctx context.Context, containerID string, options ContainerCommitOptions) (ContainerCommitResult, error)
- func (cli *Client) ContainerCreate(ctx context.Context, options ContainerCreateOptions) (ContainerCreateResult, error)
- func (cli *Client) ContainerDiff(ctx context.Context, containerID string, options ContainerDiffOptions) (ContainerDiffResult, error)
- func (cli *Client) ContainerExport(ctx context.Context, containerID string, options ContainerExportOptions) (ContainerExportResult, error)
- func (cli *Client) ContainerInspect(ctx context.Context, containerID string, options ContainerInspectOptions) (ContainerInspectResult, error)
- func (cli *Client) ContainerKill(ctx context.Context, containerID string, options ContainerKillOptions) (ContainerKillResult, error)
- func (cli *Client) ContainerList(ctx context.Context, options ContainerListOptions) (ContainerListResult, error)
- func (cli *Client) ContainerLogs(ctx context.Context, containerID string, options ContainerLogsOptions) (ContainerLogsResult, error)
- func (cli *Client) ContainerPause(ctx context.Context, containerID string, options ContainerPauseOptions) (ContainerPauseResult, error)
- func (cli *Client) ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
- func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) (ContainerRemoveResult, error)
- func (cli *Client) ContainerRename(ctx context.Context, containerID string, options ContainerRenameOptions) (ContainerRenameResult, error)
- func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) (ContainerResizeResult, error)
- func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options ContainerRestartOptions) (ContainerRestartResult, error)
- func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) (ContainerStartResult, error)
- func (cli *Client) ContainerStatPath(ctx context.Context, containerID string, options ContainerStatPathOptions) (ContainerStatPathResult, error)
- func (cli *Client) ContainerStats(ctx context.Context, containerID string, options ContainerStatsOptions) (ContainerStatsResult, error)
- func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) (ContainerStopResult, error)
- func (cli *Client) ContainerTop(ctx context.Context, containerID string, options ContainerTopOptions) (ContainerTopResult, error)
- func (cli *Client) ContainerUnpause(ctx context.Context, containerID string, options ContainerUnpauseOptions) (ContainerUnpauseResult, error)
- func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, options ContainerUpdateOptions) (ContainerUpdateResult, error)
- func (cli *Client) ContainerWait(ctx context.Context, containerID string, options ContainerWaitOptions) ContainerWaitResult
- func (cli *Client) CopyFromContainer(ctx context.Context, containerID string, options CopyFromContainerOptions) (CopyFromContainerResult, error)
- func (cli *Client) CopyToContainer(ctx context.Context, containerID string, options CopyToContainerOptions) (CopyToContainerResult, error)
- func (cli *Client) DaemonHost() string
- func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error)
- func (cli *Client) Dialer() func(context.Context) (net.Conn, error)
- func (cli *Client) DiskUsage(ctx context.Context, options DiskUsageOptions) (DiskUsageResult, error)
- func (cli *Client) DistributionInspect(ctx context.Context, imageRef string, options DistributionInspectOptions) (DistributionInspectResult, error)
- func (cli *Client) Events(ctx context.Context, options EventsListOptions) EventsResult
- func (cli *Client) ExecAttach(ctx context.Context, execID string, options ExecAttachOptions) (ExecAttachResult, error)
- func (cli *Client) ExecCreate(ctx context.Context, containerID string, options ExecCreateOptions) (ExecCreateResult, error)
- func (cli *Client) ExecInspect(ctx context.Context, execID string, options ExecInspectOptions) (ExecInspectResult, error)
- func (cli *Client) ExecResize(ctx context.Context, execID string, options ExecResizeOptions) (ExecResizeResult, error)
- func (cli *Client) ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error)
- func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResult, error)
- func (cli *Client) ImageHistory(ctx context.Context, imageID string, historyOpts ...ImageHistoryOption) (ImageHistoryResult, error)
- func (cli *Client) ImageImport(ctx context.Context, source ImageImportSource, ref string, ...) (ImageImportResult, error)
- func (cli *Client) ImageInspect(ctx context.Context, imageID string, inspectOpts ...ImageInspectOption) (ImageInspectResult, error)
- func (cli *Client) ImageList(ctx context.Context, options ImageListOptions) (ImageListResult, error)
- func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, loadOpts ...ImageLoadOption) (ImageLoadResult, error)
- func (cli *Client) ImagePrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error)
- func (cli *Client) ImagePull(ctx context.Context, refStr string, options ImagePullOptions) (ImagePullResponse, error)
- func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePushOptions) (ImagePushResponse, error)
- func (cli *Client) ImageRemove(ctx context.Context, imageID string, options ImageRemoveOptions) (ImageRemoveResult, error)
- func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ...ImageSaveOption) (ImageSaveResult, error)
- func (cli *Client) ImageSearch(ctx context.Context, term string, options ImageSearchOptions) (ImageSearchResult, error)
- func (cli *Client) ImageTag(ctx context.Context, options ImageTagOptions) (ImageTagResult, error)
- func (cli *Client) Info(ctx context.Context, options InfoOptions) (SystemInfoResult, error)
- func (cli *Client) NetworkConnect(ctx context.Context, networkID string, options NetworkConnectOptions) (NetworkConnectResult, error)
- func (cli *Client) NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (NetworkCreateResult, error)
- func (cli *Client) NetworkDisconnect(ctx context.Context, networkID string, options NetworkDisconnectOptions) (NetworkDisconnectResult, error)
- func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options NetworkInspectOptions) (NetworkInspectResult, error)
- func (cli *Client) NetworkList(ctx context.Context, options NetworkListOptions) (NetworkListResult, error)
- func (cli *Client) NetworkPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error)
- func (cli *Client) NetworkRemove(ctx context.Context, networkID string, options NetworkRemoveOptions) (NetworkRemoveResult, error)
- func (cli *Client) NodeInspect(ctx context.Context, nodeID string, options NodeInspectOptions) (NodeInspectResult, error)
- func (cli *Client) NodeList(ctx context.Context, options NodeListOptions) (NodeListResult, error)
- func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) (NodeRemoveResult, error)
- func (cli *Client) NodeUpdate(ctx context.Context, nodeID string, options NodeUpdateOptions) (NodeUpdateResult, error)
- func (cli *Client) Ping(ctx context.Context, options PingOptions) (PingResult, error)
- func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, ...) (PluginCreateResult, error)
- func (cli *Client) PluginDisable(ctx context.Context, name string, options PluginDisableOptions) (PluginDisableResult, error)
- func (cli *Client) PluginEnable(ctx context.Context, name string, options PluginEnableOptions) (PluginEnableResult, error)
- func (cli *Client) PluginInspect(ctx context.Context, name string, options PluginInspectOptions) (PluginInspectResult, error)
- func (cli *Client) PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (_ PluginInstallResult, retErr error)
- func (cli *Client) PluginList(ctx context.Context, options PluginListOptions) (PluginListResult, error)
- func (cli *Client) PluginPush(ctx context.Context, name string, options PluginPushOptions) (PluginPushResult, error)
- func (cli *Client) PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) (PluginRemoveResult, error)
- func (cli *Client) PluginSet(ctx context.Context, name string, options PluginSetOptions) (PluginSetResult, error)
- func (cli *Client) PluginUpgrade(ctx context.Context, name string, options PluginUpgradeOptions) (PluginUpgradeResult, error)
- func (cli *Client) RegistryLogin(ctx context.Context, options RegistryLoginOptions) (RegistryLoginResult, error)
- func (cli *Client) SecretCreate(ctx context.Context, options SecretCreateOptions) (SecretCreateResult, error)
- func (cli *Client) SecretInspect(ctx context.Context, id string, options SecretInspectOptions) (SecretInspectResult, error)
- func (cli *Client) SecretList(ctx context.Context, options SecretListOptions) (SecretListResult, error)
- func (cli *Client) SecretRemove(ctx context.Context, id string, options SecretRemoveOptions) (SecretRemoveResult, error)
- func (cli *Client) SecretUpdate(ctx context.Context, id string, options SecretUpdateOptions) (SecretUpdateResult, error)
- func (cli *Client) ServerVersion(ctx context.Context, _ ServerVersionOptions) (ServerVersionResult, error)
- func (cli *Client) ServiceCreate(ctx context.Context, options ServiceCreateOptions) (ServiceCreateResult, error)
- func (cli *Client) ServiceInspect(ctx context.Context, serviceID string, options ServiceInspectOptions) (ServiceInspectResult, error)
- func (cli *Client) ServiceList(ctx context.Context, options ServiceListOptions) (ServiceListResult, error)
- func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options ServiceLogsOptions) (ServiceLogsResult, error)
- func (cli *Client) ServiceRemove(ctx context.Context, serviceID string, options ServiceRemoveOptions) (ServiceRemoveResult, error)
- func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, options ServiceUpdateOptions) (ServiceUpdateResult, error)
- func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (SwarmGetUnlockKeyResult, error)
- func (cli *Client) SwarmInit(ctx context.Context, options SwarmInitOptions) (SwarmInitResult, error)
- func (cli *Client) SwarmInspect(ctx context.Context, options SwarmInspectOptions) (SwarmInspectResult, error)
- func (cli *Client) SwarmJoin(ctx context.Context, options SwarmJoinOptions) (SwarmJoinResult, error)
- func (cli *Client) SwarmLeave(ctx context.Context, options SwarmLeaveOptions) (SwarmLeaveResult, error)
- func (cli *Client) SwarmUnlock(ctx context.Context, options SwarmUnlockOptions) (SwarmUnlockResult, error)
- func (cli *Client) SwarmUpdate(ctx context.Context, options SwarmUpdateOptions) (SwarmUpdateResult, error)
- func (cli *Client) TaskInspect(ctx context.Context, taskID string, options TaskInspectOptions) (TaskInspectResult, error)
- func (cli *Client) TaskList(ctx context.Context, options TaskListOptions) (TaskListResult, error)
- func (cli *Client) TaskLogs(ctx context.Context, taskID string, options TaskLogsOptions) (TaskLogsResult, error)
- func (cli *Client) VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error)
- func (cli *Client) VolumeInspect(ctx context.Context, volumeID string, options VolumeInspectOptions) (VolumeInspectResult, error)
- func (cli *Client) VolumeList(ctx context.Context, options VolumeListOptions) (VolumeListResult, error)
- func (cli *Client) VolumePrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error)
- func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, options VolumeRemoveOptions) (VolumeRemoveResult, error)
- func (cli *Client) VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error)
- type CloseWriter
- type ConfigAPIClient
- type ConfigCreateOptions
- type ConfigCreateResult
- type ConfigInspectOptions
- type ConfigInspectResult
- type ConfigListOptions
- type ConfigListResult
- type ConfigRemoveOptions
- type ConfigRemoveResult
- type ConfigUpdateOptions
- type ConfigUpdateResult
- type ConsoleSize
- type ContainerAPIClient
- type ContainerAttachOptions
- type ContainerAttachResult
- type ContainerCommitOptions
- type ContainerCommitResult
- type ContainerCreateOptions
- type ContainerCreateResult
- type ContainerDiffOptions
- type ContainerDiffResult
- type ContainerExportOptions
- type ContainerExportResult
- type ContainerInspectOptions
- type ContainerInspectResult
- type ContainerKillOptions
- type ContainerKillResult
- type ContainerListOptions
- type ContainerListResult
- type ContainerLogsOptions
- type ContainerLogsResult
- type ContainerPauseOptions
- type ContainerPauseResult
- type ContainerPruneOptions
- type ContainerPruneResult
- type ContainerRemoveOptions
- type ContainerRemoveResult
- type ContainerRenameOptions
- type ContainerRenameResult
- type ContainerResizeOptions
- type ContainerResizeResult
- type ContainerRestartOptions
- type ContainerRestartResult
- type ContainerStartOptions
- type ContainerStartResult
- type ContainerStatPathOptions
- type ContainerStatPathResult
- type ContainerStatsOptions
- type ContainerStatsResult
- type ContainerStopOptions
- type ContainerStopResult
- type ContainerTopOptions
- type ContainerTopResult
- type ContainerUnpauseOptions
- type ContainerUnpauseResult
- type ContainerUpdateOptions
- type ContainerUpdateResult
- type ContainerWaitOptions
- type ContainerWaitResult
- type ContainersDiskUsage
- type CopyFromContainerOptions
- type CopyFromContainerResult
- type CopyToContainerOptions
- type CopyToContainerResult
- type DiskUsageOptions
- type DiskUsageResult
- type DistributionAPIClient
- type DistributionInspectOptions
- type DistributionInspectResult
- type EventsListOptions
- type EventsResult
- type ExecAPIClient
- type ExecAttachOptions
- type ExecAttachResult
- type ExecCreateOptions
- type ExecCreateResult
- type ExecInspectOptions
- type ExecInspectResult
- type ExecResizeOptions
- type ExecResizeResult
- type ExecStartOptions
- type ExecStartResult
- type Filters
- type HijackDialer
- type HijackedResponse
- type ImageAPIClient
- type ImageBuildAPIClient
- type ImageBuildOptions
- type ImageBuildOutput
- type ImageBuildResult
- type ImageHistoryOption
- type ImageHistoryResult
- type ImageImportOptions
- type ImageImportResult
- type ImageImportSource
- type ImageInspectOption
- type ImageInspectResult
- type ImageListOptions
- type ImageListResult
- type ImageLoadOption
- type ImageLoadResult
- type ImagePruneOptions
- type ImagePruneResult
- type ImagePullOptions
- type ImagePullResponse
- type ImagePushOptions
- type ImagePushResponse
- type ImageRemoveOptions
- type ImageRemoveResult
- type ImageSaveOption
- type ImageSaveResult
- type ImageSearchOptions
- type ImageSearchResult
- type ImageTagOptions
- type ImageTagResult
- type ImagesDiskUsage
- type InfoOptions
- type NetworkAPIClient
- type NetworkConnectOptions
- type NetworkConnectResult
- type NetworkCreateOptions
- type NetworkCreateResult
- type NetworkDisconnectOptions
- type NetworkDisconnectResult
- type NetworkInspectOptions
- type NetworkInspectResult
- type NetworkListOptions
- type NetworkListResult
- type NetworkPruneOptions
- type NetworkPruneResult
- type NetworkRemoveOptions
- type NetworkRemoveResult
- type NodeAPIClient
- type NodeInspectOptions
- type NodeInspectResult
- type NodeListOptions
- type NodeListResult
- type NodeRemoveOptions
- type NodeRemoveResult
- type NodeUpdateOptions
- type NodeUpdateResult
- type Opt
- func WithAPIVersionNegotiation() Opt
- func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) Opt
- func WithHTTPClient(client *http.Client) Opt
- func WithHTTPHeaders(headers map[string]string) Opt
- func WithHost(host string) Opt
- func WithHostFromEnv() Opt
- func WithScheme(scheme string) Opt
- func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt
- func WithTLSClientConfigFromEnv() Opt
- func WithTimeout(timeout time.Duration) Opt
- func WithTraceOptions(opts ...otelhttp.Option) Opt
- func WithTraceProvider(provider trace.TracerProvider) Opt
- func WithUserAgent(ua string) Opt
- func WithVersion(version string) Opt
- func WithVersionFromEnv() Opt
- type PingOptions
- type PingResult
- type PlatformInfo
- type PluginAPIClient
- type PluginCreateOptions
- type PluginCreateResult
- type PluginDisableOptions
- type PluginDisableResult
- type PluginEnableOptions
- type PluginEnableResult
- type PluginInspectOptions
- type PluginInspectResult
- type PluginInstallOptions
- type PluginInstallResult
- type PluginListOptions
- type PluginListResult
- type PluginPushOptions
- type PluginPushResult
- type PluginRemoveOptions
- type PluginRemoveResult
- type PluginSetOptions
- type PluginSetResult
- type PluginUpgradeOptions
- type PluginUpgradeResult
- type RegistryLoginOptions
- type RegistryLoginResult
- type RegistrySearchClient
- type SecretAPIClient
- type SecretCreateOptions
- type SecretCreateResult
- type SecretInspectOptions
- type SecretInspectResult
- type SecretListOptions
- type SecretListResult
- type SecretRemoveOptions
- type SecretRemoveResult
- type SecretUpdateOptions
- type SecretUpdateResult
- type ServerVersionOptions
- type ServerVersionResult
- type ServiceAPIClient
- type ServiceCreateOptions
- type ServiceCreateResult
- type ServiceInspectOptions
- type ServiceInspectResult
- type ServiceListOptions
- type ServiceListResult
- type ServiceLogsOptions
- type ServiceLogsResult
- type ServiceRemoveOptions
- type ServiceRemoveResult
- type ServiceUpdateOptions
- type ServiceUpdateResult
- type SwarmAPIClient
- type SwarmGetUnlockKeyResult
- type SwarmInitOptions
- type SwarmInitResult
- type SwarmInspectOptions
- type SwarmInspectResult
- type SwarmJoinOptions
- type SwarmJoinResult
- type SwarmLeaveOptions
- type SwarmLeaveResult
- type SwarmManagementAPIClient
- type SwarmStatus
- type SwarmUnlockOptions
- type SwarmUnlockResult
- type SwarmUpdateOptions
- type SwarmUpdateResult
- type SystemAPIClient
- type SystemInfoResult
- type TaskAPIClient
- type TaskInspectOptions
- type TaskInspectResult
- type TaskListOptions
- type TaskListResult
- type TaskLogsOptions
- type TaskLogsResult
- type VolumeAPIClient
- type VolumeCreateOptions
- type VolumeCreateResult
- type VolumeInspectOptions
- type VolumeInspectResult
- type VolumeListOptions
- type VolumeListResult
- type VolumePruneOptions
- type VolumePruneResult
- type VolumeRemoveOptions
- type VolumeRemoveResult
- type VolumeUpdateOptions
- type VolumeUpdateResult
- type VolumesDiskUsage
Examples ¶
Constants ¶
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" )
const DefaultDockerHost = "unix:///var/run/docker.sock"
DefaultDockerHost defines OS-specific default host if the DOCKER_HOST (EnvOverrideHost) environment variable is unset or empty.
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:
- https://github.com/docker/engine-api/issues/189
- https://github.com/golang/go/issues/13624
- https://github.com/golang/go/issues/61076
- https://github.com/moby/moby/issues/45935
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 ¶
var ErrRedirect = errors.New("unexpected redirect in response")
ErrRedirect is the error returned by checkRedirect when the request is non-GET.
Functions ¶
func CheckRedirect ¶
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 ¶
IsErrConnectionFailed returns true if the error is caused by connection failed.
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 BuildCacheDiskUsage ¶
type BuildCacheDiskUsage struct {
// ActiveCount is the number of active build cache records.
ActiveCount int64
// TotalCount is the total number of build cache records.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
// TotalSize is the total disk space used by all build cache records.
TotalSize int64
// Items holds detailed information about each build cache record.
Items []build.CacheRecord
}
BuildCacheDiskUsage contains disk usage information for build cache.
type BuildCachePruneOptions ¶
type BuildCachePruneOptions struct {
All bool
ReservedSpace int64
MaxUsedSpace int64
MinFreeSpace int64
Filters Filters
}
BuildCachePruneOptions hold parameters to prune the build cache.
type BuildCachePruneResult ¶
type BuildCachePruneResult struct {
Report build.CachePruneReport
}
BuildCachePruneResult holds the result from the BuildCachePrune method.
type BuildCancelOptions ¶
type BuildCancelOptions struct{}
type BuildCancelResult ¶
type BuildCancelResult struct{}
type CheckpointAPIClient ¶
type CheckpointAPIClient interface {
CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error)
CheckpointRemove(ctx context.Context, container string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error)
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, 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 ¶
CheckpointCreateOptions holds parameters to create a checkpoint from a container.
type CheckpointCreateResult ¶
type CheckpointCreateResult struct {
}
CheckpointCreateResult holds the result from client.CheckpointCreate.
type CheckpointListOptions ¶
type CheckpointListOptions struct {
CheckpointDir string
}
CheckpointListOptions holds parameters to list checkpoints for a container.
type CheckpointListResult ¶
type CheckpointListResult struct {
Items []checkpoint.Summary
}
CheckpointListResult holds the result from the CheckpointList method.
type CheckpointRemoveOptions ¶
CheckpointRemoveOptions holds parameters to delete a checkpoint from a container.
type CheckpointRemoveResult ¶
type CheckpointRemoveResult struct {
}
CheckpointRemoveResult represents the result of Client.CheckpointRemove.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the API client that performs all operations against a docker server.
func New ¶
New 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.New( client.FromEnv, client.WithAPIVersionNegotiation(), )
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/moby/moby/client"
)
func main() {
// Create a new client that handles common environment variables
// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
// API-version negotiation to allow downgrading the API version
// when connecting with an older daemon version.
apiClient, err := client.New(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
log.Fatal(err)
}
// List all containers (both stopped and running).
result, err := apiClient.ContainerList(context.Background(), client.ContainerListOptions{
All: true,
})
if err != nil {
log.Fatal(err)
}
// Print each container's ID, status and the image it was created from.
fmt.Printf("%s %-22s %s\n", "ID", "STATUS", "IMAGE")
for _, ctr := range result.Items {
fmt.Printf("%s %-22s %s\n", ctr.ID, ctr.Status, ctr.Image)
}
}
func NewClientWithOpts
deprecated
func (*Client) BuildCachePrune ¶
func (cli *Client) BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (BuildCachePruneResult, error)
BuildCachePrune requests the daemon to delete unused cache data.
func (*Client) BuildCancel ¶
func (cli *Client) BuildCancel(ctx context.Context, id string, _ BuildCancelOptions) (BuildCancelResult, 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) (CheckpointCreateResult, error)
CheckpointCreate creates a checkpoint from the given container.
func (*Client) CheckpointList ¶
func (cli *Client) CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
CheckpointList returns the checkpoints of the given container in the docker host.
func (*Client) CheckpointRemove ¶
func (cli *Client) CheckpointRemove(ctx context.Context, containerID string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error)
CheckpointRemove deletes the checkpoint with the given name from the given container.
func (*Client) ClientVersion ¶
ClientVersion returns the API version used by this client.
func (*Client) ConfigCreate ¶
func (cli *Client) ConfigCreate(ctx context.Context, options ConfigCreateOptions) (ConfigCreateResult, error)
ConfigCreate creates a new config.
func (*Client) ConfigInspect ¶
func (cli *Client) ConfigInspect(ctx context.Context, id string, options ConfigInspectOptions) (ConfigInspectResult, error)
ConfigInspect returns the config information with raw data
func (*Client) ConfigList ¶
func (cli *Client) ConfigList(ctx context.Context, options ConfigListOptions) (ConfigListResult, error)
ConfigList returns the list of configs.
func (*Client) ConfigRemove ¶
func (cli *Client) ConfigRemove(ctx context.Context, id string, options ConfigRemoveOptions) (ConfigRemoveResult, error)
ConfigRemove removes a config.
func (*Client) ConfigUpdate ¶
func (cli *Client) ConfigUpdate(ctx context.Context, id string, options ConfigUpdateOptions) (ConfigUpdateResult, error)
ConfigUpdate attempts to update a config
func (*Client) ContainerAttach ¶
func (cli *Client) ContainerAttach(ctx context.Context, containerID string, options ContainerAttachOptions) (ContainerAttachResult, 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) (ContainerCommitResult, error)
ContainerCommit applies changes to a container and creates a new tagged image.
func (*Client) ContainerCreate ¶
func (cli *Client) ContainerCreate(ctx context.Context, options ContainerCreateOptions) (ContainerCreateResult, 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, options ContainerDiffOptions) (ContainerDiffResult, error)
ContainerDiff shows differences in a container filesystem since it was started.
func (*Client) ContainerExport ¶
func (cli *Client) ContainerExport(ctx context.Context, containerID string, options ContainerExportOptions) (ContainerExportResult, 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.
The underlying io.ReadCloser is automatically closed if the context is canceled,
func (*Client) ContainerInspect ¶
func (cli *Client) ContainerInspect(ctx context.Context, containerID string, options ContainerInspectOptions) (ContainerInspectResult, error)
ContainerInspect returns the container information.
func (*Client) ContainerKill ¶
func (cli *Client) ContainerKill(ctx context.Context, containerID string, options ContainerKillOptions) (ContainerKillResult, 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) (ContainerListResult, 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) (ContainerLogsResult, error)
ContainerLogs returns the logs generated by a container in an io.ReadCloser. It's up to the caller to close the stream.
The underlying io.ReadCloser is automatically closed if the context is canceled,
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) ¶
client, err := New(FromEnv, WithAPIVersionNegotiation())
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
res, err := client.ContainerLogs(ctx, "container_id", ContainerLogsOptions{})
if err != nil {
log.Fatal(err)
}
defer res.Close()
_, err = io.Copy(os.Stdout, res)
if err != nil && !errors.Is(err, io.EOF) {
log.Fatal(err)
}
func (*Client) ContainerPause ¶
func (cli *Client) ContainerPause(ctx context.Context, containerID string, options ContainerPauseOptions) (ContainerPauseResult, error)
ContainerPause pauses the main process of a given container without terminating it.
func (*Client) ContainerPrune ¶
func (cli *Client) ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
ContainerPrune requests the daemon to delete unused data
func (*Client) ContainerRemove ¶
func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) (ContainerRemoveResult, error)
ContainerRemove kills and removes a container from the docker host.
func (*Client) ContainerRename ¶
func (cli *Client) ContainerRename(ctx context.Context, containerID string, options ContainerRenameOptions) (ContainerRenameResult, error)
ContainerRename changes the name of a given container.
func (*Client) ContainerResize ¶
func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) (ContainerResizeResult, 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 ContainerRestartOptions) (ContainerRestartResult, 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) (ContainerStartResult, error)
ContainerStart sends a request to the docker daemon to start a container.
func (*Client) ContainerStatPath ¶
func (cli *Client) ContainerStatPath(ctx context.Context, containerID string, options ContainerStatPathOptions) (ContainerStatPathResult, error)
ContainerStatPath returns stat information about a path inside the container filesystem.
func (*Client) ContainerStats ¶
func (cli *Client) ContainerStats(ctx context.Context, containerID string, options ContainerStatsOptions) (ContainerStatsResult, error)
ContainerStats retrieves live resource usage statistics for the specified container. The caller must close the io.ReadCloser in the returned result to release associated resources.
The underlying io.ReadCloser is automatically closed if the context is canceled,
func (*Client) ContainerStop ¶
func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) (ContainerStopResult, 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, options ContainerTopOptions) (ContainerTopResult, error)
ContainerTop shows process information from within a container.
func (*Client) ContainerUnpause ¶
func (cli *Client) ContainerUnpause(ctx context.Context, containerID string, options ContainerUnpauseOptions) (ContainerUnpauseResult, error)
ContainerUnpause resumes the process execution within a container.
func (*Client) ContainerUpdate ¶
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, options ContainerUpdateOptions) (ContainerUpdateResult, error)
ContainerUpdate updates the resources of a container.
func (*Client) ContainerWait ¶
func (cli *Client) ContainerWait(ctx context.Context, containerID string, options ContainerWaitOptions) ContainerWaitResult
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)
- "removed" (container.WaitConditionRemoved)
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, _ := New(FromEnv)
wait := client.ContainerWait(ctx, "container_id", ContainerWaitOptions{})
if err := <-wait.Error; err != nil {
log.Fatal(err)
}
func (*Client) CopyFromContainer ¶
func (cli *Client) CopyFromContainer(ctx context.Context, containerID string, options CopyFromContainerOptions) (CopyFromContainerResult, 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 string, options CopyToContainerOptions) (CopyToContainerResult, error)
CopyToContainer copies content into the container filesystem. Note that `content` must be a Reader for a TAR archive
func (*Client) DaemonHost ¶
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 ¶
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) (DiskUsageResult, error)
DiskUsage requests the current data usage from the daemon.
func (*Client) DistributionInspect ¶
func (cli *Client) DistributionInspect(ctx context.Context, imageRef string, options DistributionInspectOptions) (DistributionInspectResult, error)
DistributionInspect returns the image digest with the full manifest.
func (*Client) Events ¶
func (cli *Client) Events(ctx context.Context, options EventsListOptions) EventsResult
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) ExecAttach ¶
func (cli *Client) ExecAttach(ctx context.Context, execID string, options ExecAttachOptions) (ExecAttachResult, error)
ExecAttach 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) ExecCreate ¶
func (cli *Client) ExecCreate(ctx context.Context, containerID string, options ExecCreateOptions) (ExecCreateResult, error)
ExecCreate creates a new exec configuration to run an exec process.
func (*Client) ExecInspect ¶
func (cli *Client) ExecInspect(ctx context.Context, execID string, options ExecInspectOptions) (ExecInspectResult, error)
ExecInspect returns information about a specific exec process on the docker host.
func (*Client) ExecResize ¶
func (cli *Client) ExecResize(ctx context.Context, execID string, options ExecResizeOptions) (ExecResizeResult, error)
ExecResize changes the size of the tty for an exec process running inside a container.
func (*Client) ExecStart ¶
func (cli *Client) ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error)
ExecStart starts an exec process already created in the docker host.
func (*Client) ImageBuild ¶
func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResult, 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) ImageHistory ¶
func (cli *Client) ImageHistory(ctx context.Context, imageID string, historyOpts ...ImageHistoryOption) (ImageHistoryResult, 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) (ImageImportResult, error)
ImageImport creates a new image based on the source options. It returns the JSON content in the ImageImportResult.
The underlying io.ReadCloser is automatically closed if the context is canceled,
func (*Client) ImageInspect ¶
func (cli *Client) ImageInspect(ctx context.Context, imageID string, inspectOpts ...ImageInspectOption) (ImageInspectResult, error)
ImageInspect returns the image information.
func (*Client) ImageList ¶
func (cli *Client) ImageList(ctx context.Context, options ImageListOptions) (ImageListResult, 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) (ImageLoadResult, error)
ImageLoad loads an image in the docker host from the client host. It's up to the caller to close the ImageLoadResult returned by this function.
The underlying io.ReadCloser is automatically closed if the context is canceled,
func (*Client) ImagePrune ¶
func (cli *Client) ImagePrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error)
ImagePrune requests the daemon to delete unused data
func (*Client) ImagePull ¶
func (cli *Client) ImagePull(ctx context.Context, refStr string, options ImagePullOptions) (ImagePullResponse, 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. Callers can:
- use [ImagePullResponse.Wait] to wait for pull to complete
- use [ImagePullResponse.JSONMessages] to monitor pull progress as a sequence of JSONMessages, [ImagePullResponse.Close] does not need to be called in this case.
- use the io.Reader interface and call [ImagePullResponse.Close] after processing.
func (*Client) ImagePush ¶
func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePushOptions) (ImagePushResponse, 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. Callers can
- use [ImagePushResponse.Wait] to wait for push to complete
- use [ImagePushResponse.JSONMessages] to monitor pull progress as a sequence of JSONMessages, [ImagePushResponse.Close] does not need to be called in this case.
- use the io.Reader interface and call [ImagePushResponse.Close] after processing.
func (*Client) ImageRemove ¶
func (cli *Client) ImageRemove(ctx context.Context, imageID string, options ImageRemoveOptions) (ImageRemoveResult, error)
ImageRemove removes an image from the docker host.
func (*Client) ImageSave ¶
func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ...ImageSaveOption) (ImageSaveResult, error)
ImageSave retrieves one or more images from the docker host as an ImageSaveResult. Callers should close the reader, but the underlying io.ReadCloser is automatically closed if the context is canceled,
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) (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 (cli *Client) ImageTag(ctx context.Context, options ImageTagOptions) (ImageTagResult, error)
ImageTag tags an image in the docker host
func (*Client) Info ¶
func (cli *Client) Info(ctx context.Context, options InfoOptions) (SystemInfoResult, error)
Info returns information about the docker server.
func (*Client) NetworkConnect ¶
func (cli *Client) NetworkConnect(ctx context.Context, networkID string, options NetworkConnectOptions) (NetworkConnectResult, 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) (NetworkCreateResult, error)
NetworkCreate creates a new network in the docker host.
func (*Client) NetworkDisconnect ¶
func (cli *Client) NetworkDisconnect(ctx context.Context, networkID string, options NetworkDisconnectOptions) (NetworkDisconnectResult, 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) (NetworkInspectResult, error)
NetworkInspect returns the information for a specific network configured in the docker host.
func (*Client) NetworkList ¶
func (cli *Client) NetworkList(ctx context.Context, options NetworkListOptions) (NetworkListResult, error)
NetworkList returns the list of networks configured in the docker host.
func (*Client) NetworkPrune ¶
func (cli *Client) NetworkPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error)
NetworkPrune requests the daemon to delete unused networks
func (*Client) NetworkRemove ¶
func (cli *Client) NetworkRemove(ctx context.Context, networkID string, options NetworkRemoveOptions) (NetworkRemoveResult, error)
NetworkRemove removes an existent network from the docker host.
func (*Client) NodeInspect ¶
func (cli *Client) NodeInspect(ctx context.Context, nodeID string, options NodeInspectOptions) (NodeInspectResult, error)
NodeInspect returns the node information.
func (*Client) NodeList ¶
func (cli *Client) NodeList(ctx context.Context, options NodeListOptions) (NodeListResult, error)
NodeList returns the list of nodes.
func (*Client) NodeRemove ¶
func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) (NodeRemoveResult, error)
NodeRemove removes a Node.
func (*Client) NodeUpdate ¶
func (cli *Client) NodeUpdate(ctx context.Context, nodeID string, options NodeUpdateOptions) (NodeUpdateResult, error)
NodeUpdate updates a Node.
func (*Client) Ping ¶
func (cli *Client) Ping(ctx context.Context, options PingOptions) (PingResult, 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) (PluginCreateResult, error)
PluginCreate creates a plugin
func (*Client) PluginDisable ¶
func (cli *Client) PluginDisable(ctx context.Context, name string, options PluginDisableOptions) (PluginDisableResult, error)
PluginDisable disables a plugin
func (*Client) PluginEnable ¶
func (cli *Client) PluginEnable(ctx context.Context, name string, options PluginEnableOptions) (PluginEnableResult, error)
PluginEnable enables a plugin
func (*Client) PluginInspect ¶
func (cli *Client) PluginInspect(ctx context.Context, name string, options PluginInspectOptions) (PluginInspectResult, error)
PluginInspect inspects an existing plugin
func (*Client) PluginInstall ¶
func (cli *Client) PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (_ PluginInstallResult, retErr error)
PluginInstall installs a plugin
func (*Client) PluginList ¶
func (cli *Client) PluginList(ctx context.Context, options PluginListOptions) (PluginListResult, error)
PluginList returns the installed plugins
func (*Client) PluginPush ¶
func (cli *Client) PluginPush(ctx context.Context, name string, options PluginPushOptions) (PluginPushResult, error)
PluginPush pushes a plugin to a registry
func (*Client) PluginRemove ¶
func (cli *Client) PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) (PluginRemoveResult, error)
PluginRemove removes a plugin
func (*Client) PluginSet ¶
func (cli *Client) PluginSet(ctx context.Context, name string, options PluginSetOptions) (PluginSetResult, error)
PluginSet modifies settings for an existing plugin
func (*Client) PluginUpgrade ¶
func (cli *Client) PluginUpgrade(ctx context.Context, name string, options PluginUpgradeOptions) (PluginUpgradeResult, error)
PluginUpgrade upgrades a plugin
func (*Client) RegistryLogin ¶
func (cli *Client) RegistryLogin(ctx context.Context, options RegistryLoginOptions) (RegistryLoginResult, 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, options SecretCreateOptions) (SecretCreateResult, error)
SecretCreate creates a new secret.
func (*Client) SecretInspect ¶
func (cli *Client) SecretInspect(ctx context.Context, id string, options SecretInspectOptions) (SecretInspectResult, error)
SecretInspect returns the secret information with raw data.
func (*Client) SecretList ¶
func (cli *Client) SecretList(ctx context.Context, options SecretListOptions) (SecretListResult, error)
SecretList returns the list of secrets.
func (*Client) SecretRemove ¶
func (cli *Client) SecretRemove(ctx context.Context, id string, options SecretRemoveOptions) (SecretRemoveResult, error)
SecretRemove removes a secret.
func (*Client) SecretUpdate ¶
func (cli *Client) SecretUpdate(ctx context.Context, id string, options SecretUpdateOptions) (SecretUpdateResult, error)
SecretUpdate attempts to update a secret.
func (*Client) ServerVersion ¶
func (cli *Client) ServerVersion(ctx context.Context, _ ServerVersionOptions) (ServerVersionResult, error)
ServerVersion returns information of the Docker server host.
func (*Client) ServiceCreate ¶
func (cli *Client) ServiceCreate(ctx context.Context, options ServiceCreateOptions) (ServiceCreateResult, error)
ServiceCreate creates a new service.
func (*Client) ServiceInspect ¶
func (cli *Client) ServiceInspect(ctx context.Context, serviceID string, options ServiceInspectOptions) (ServiceInspectResult, error)
ServiceInspect retrieves detailed information about a specific service by its ID.
func (*Client) ServiceList ¶
func (cli *Client) ServiceList(ctx context.Context, options ServiceListOptions) (ServiceListResult, error)
ServiceList returns the list of services.
func (*Client) ServiceLogs ¶
func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options ServiceLogsOptions) (ServiceLogsResult, error)
ServiceLogs returns the logs generated by a service in a ServiceLogsResult. as an io.ReadCloser. Callers should close the stream.
The underlying io.ReadCloser is automatically closed if the context is canceled,
Example (WithTimeout) ¶
client, err := New(FromEnv, WithAPIVersionNegotiation())
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
res, err := client.ServiceLogs(ctx, "service_id", ServiceLogsOptions{})
if err != nil {
log.Fatal(err)
}
defer res.Close()
_, err = io.Copy(os.Stdout, res)
if err != nil && !errors.Is(err, io.EOF) {
log.Fatal(err)
}
func (*Client) ServiceRemove ¶
func (cli *Client) ServiceRemove(ctx context.Context, serviceID string, options ServiceRemoveOptions) (ServiceRemoveResult, error)
ServiceRemove kills and removes a service.
func (*Client) ServiceUpdate ¶
func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, options ServiceUpdateOptions) (ServiceUpdateResult, 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) (SwarmGetUnlockKeyResult, error)
SwarmGetUnlockKey retrieves the swarm's unlock key.
func (*Client) SwarmInit ¶
func (cli *Client) SwarmInit(ctx context.Context, options SwarmInitOptions) (SwarmInitResult, error)
SwarmInit initializes the swarm.
func (*Client) SwarmInspect ¶
func (cli *Client) SwarmInspect(ctx context.Context, options SwarmInspectOptions) (SwarmInspectResult, error)
SwarmInspect inspects the swarm.
func (*Client) SwarmJoin ¶
func (cli *Client) SwarmJoin(ctx context.Context, options SwarmJoinOptions) (SwarmJoinResult, error)
SwarmJoin joins the swarm.
func (*Client) SwarmLeave ¶
func (cli *Client) SwarmLeave(ctx context.Context, options SwarmLeaveOptions) (SwarmLeaveResult, error)
SwarmLeave leaves the swarm.
func (*Client) SwarmUnlock ¶
func (cli *Client) SwarmUnlock(ctx context.Context, options SwarmUnlockOptions) (SwarmUnlockResult, error)
SwarmUnlock unlocks locked swarm.
func (*Client) SwarmUpdate ¶
func (cli *Client) SwarmUpdate(ctx context.Context, options SwarmUpdateOptions) (SwarmUpdateResult, error)
SwarmUpdate updates the swarm.
func (*Client) TaskInspect ¶
func (cli *Client) TaskInspect(ctx context.Context, taskID string, options TaskInspectOptions) (TaskInspectResult, error)
TaskInspect returns the task information and its raw representation.
func (*Client) TaskList ¶
func (cli *Client) TaskList(ctx context.Context, options TaskListOptions) (TaskListResult, error)
TaskList returns the list of tasks.
func (*Client) TaskLogs ¶
func (cli *Client) TaskLogs(ctx context.Context, taskID string, options TaskLogsOptions) (TaskLogsResult, error)
TaskLogs returns the logs generated by a service in a TaskLogsResult. as an io.ReadCloser. Callers should close the stream.
The underlying io.ReadCloser is automatically closed if the context is canceled,
func (*Client) VolumeCreate ¶
func (cli *Client) VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error)
VolumeCreate creates a volume in the docker host.
func (*Client) VolumeInspect ¶
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string, options VolumeInspectOptions) (VolumeInspectResult, error)
VolumeInspect returns the information about a specific volume in the docker host.
func (*Client) VolumeList ¶
func (cli *Client) VolumeList(ctx context.Context, options VolumeListOptions) (VolumeListResult, error)
VolumeList returns the volumes configured in the docker host.
func (*Client) VolumePrune ¶
func (cli *Client) VolumePrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error)
VolumePrune requests the daemon to delete unused data
func (*Client) VolumeRemove ¶
func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, options VolumeRemoveOptions) (VolumeRemoveResult, error)
VolumeRemove removes a volume from the docker host.
func (*Client) VolumeUpdate ¶
func (cli *Client) VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error)
VolumeUpdate updates a volume. This only works for Cluster Volumes, and only some fields can be updated.
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 {
ConfigCreate(ctx context.Context, options ConfigCreateOptions) (ConfigCreateResult, error)
ConfigInspect(ctx context.Context, id string, options ConfigInspectOptions) (ConfigInspectResult, error)
ConfigList(ctx context.Context, options ConfigListOptions) (ConfigListResult, error)
ConfigUpdate(ctx context.Context, id string, options ConfigUpdateOptions) (ConfigUpdateResult, error)
ConfigRemove(ctx context.Context, id string, options ConfigRemoveOptions) (ConfigRemoveResult, error)
}
ConfigAPIClient defines API client methods for configs
type ConfigCreateOptions ¶
type ConfigCreateOptions struct {
Spec swarm.ConfigSpec
}
ConfigCreateOptions holds options for creating a config.
type ConfigCreateResult ¶
type ConfigCreateResult struct {
ID string
}
ConfigCreateResult holds the result from the ConfigCreate method.
type ConfigInspectOptions ¶
type ConfigInspectOptions struct {
}
ConfigInspectOptions holds options for inspecting a config.
type ConfigInspectResult ¶
type ConfigInspectResult struct {
Config swarm.Config
Raw json.RawMessage
}
ConfigInspectResult holds the result from the ConfigInspect method.
type ConfigListOptions ¶
type ConfigListOptions struct {
Filters Filters
}
ConfigListOptions holds parameters to list configs
type ConfigListResult ¶
ConfigListResult holds the result from the client.ConfigList method.
type ConfigRemoveOptions ¶
type ConfigRemoveOptions struct {
}
type ConfigRemoveResult ¶
type ConfigRemoveResult struct {
}
type ConfigUpdateOptions ¶
type ConfigUpdateOptions struct {
Version swarm.Version
Spec swarm.ConfigSpec
}
ConfigUpdateOptions holds options for updating a config.
type ConfigUpdateResult ¶
type ConfigUpdateResult struct{}
type ConsoleSize ¶
type ConsoleSize struct {
Height, Width uint
}
type ContainerAPIClient ¶
type ContainerAPIClient interface {
ContainerCreate(ctx context.Context, options ContainerCreateOptions) (ContainerCreateResult, error)
ContainerInspect(ctx context.Context, container string, options ContainerInspectOptions) (ContainerInspectResult, error)
ContainerList(ctx context.Context, options ContainerListOptions) (ContainerListResult, error)
ContainerUpdate(ctx context.Context, container string, updateConfig ContainerUpdateOptions) (ContainerUpdateResult, error)
ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) (ContainerRemoveResult, error)
ContainerPrune(ctx context.Context, opts ContainerPruneOptions) (ContainerPruneResult, error)
ContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (ContainerLogsResult, error)
ContainerStart(ctx context.Context, container string, options ContainerStartOptions) (ContainerStartResult, error)
ContainerStop(ctx context.Context, container string, options ContainerStopOptions) (ContainerStopResult, error)
ContainerRestart(ctx context.Context, container string, options ContainerRestartOptions) (ContainerRestartResult, error)
ContainerPause(ctx context.Context, container string, options ContainerPauseOptions) (ContainerPauseResult, error)
ContainerUnpause(ctx context.Context, container string, options ContainerUnpauseOptions) (ContainerUnpauseResult, error)
ContainerWait(ctx context.Context, container string, options ContainerWaitOptions) ContainerWaitResult
ContainerKill(ctx context.Context, container string, options ContainerKillOptions) (ContainerKillResult, error)
ContainerRename(ctx context.Context, container string, options ContainerRenameOptions) (ContainerRenameResult, error)
ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) (ContainerResizeResult, error)
ContainerAttach(ctx context.Context, container string, options ContainerAttachOptions) (ContainerAttachResult, error)
ContainerCommit(ctx context.Context, container string, options ContainerCommitOptions) (ContainerCommitResult, error)
ContainerDiff(ctx context.Context, container string, options ContainerDiffOptions) (ContainerDiffResult, error)
ContainerExport(ctx context.Context, container string, options ContainerExportOptions) (ContainerExportResult, error)
ContainerStats(ctx context.Context, container string, options ContainerStatsOptions) (ContainerStatsResult, error)
ContainerTop(ctx context.Context, container string, options ContainerTopOptions) (ContainerTopResult, error)
ContainerStatPath(ctx context.Context, container string, options ContainerStatPathOptions) (ContainerStatPathResult, error)
CopyFromContainer(ctx context.Context, container string, options CopyFromContainerOptions) (CopyFromContainerResult, error)
CopyToContainer(ctx context.Context, container string, options CopyToContainerOptions) (CopyToContainerResult, 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 ContainerAttachResult ¶
type ContainerAttachResult struct {
HijackedResponse
}
ContainerAttachResult is the result from attaching to a container.
type ContainerCommitOptions ¶
type ContainerCommitOptions struct {
Reference string
Comment string
Author string
Changes []string
NoPause bool // NoPause disables pausing the container during commit.
Config *container.Config
}
ContainerCommitOptions holds parameters to commit changes into a container.
type ContainerCommitResult ¶
type ContainerCommitResult struct {
ID string
}
ContainerCommitResult is the result from committing a container.
type ContainerCreateOptions ¶
type ContainerCreateOptions struct {
Config *container.Config
HostConfig *container.HostConfig
NetworkingConfig *network.NetworkingConfig
Platform *ocispec.Platform
Name string
// Image is a shortcut for Config.Image - only one of Image or Config.Image should be set.
Image string
}
ContainerCreateOptions holds parameters to create a container.
type ContainerCreateResult ¶
ContainerCreateResult is the result from creating a container.
type ContainerDiffOptions ¶
type ContainerDiffOptions struct {
}
ContainerDiffOptions holds parameters to show differences in a container filesystem.
type ContainerDiffResult ¶
type ContainerDiffResult struct {
Changes []container.FilesystemChange
}
ContainerDiffResult is the result from showing differences in a container filesystem.
type ContainerExportOptions ¶
type ContainerExportOptions struct {
}
ContainerExportOptions specifies options for container export operations.
type ContainerExportResult ¶
type ContainerExportResult interface {
io.ReadCloser
}
ContainerExportResult represents the result of a container export operation.
type ContainerInspectOptions ¶
type ContainerInspectOptions struct {
// Size controls whether the container's filesystem size should be calculated.
// When set, the [container.InspectResponse.SizeRw] and [container.InspectResponse.SizeRootFs]
// fields in [ContainerInspectResult.Container] are populated with the result.
//
// Calculating the size can be a costly operation, and should not be used
// unless needed.
Size bool
}
ContainerInspectOptions holds options for inspecting a container using the Client.ConfigInspect method.
type ContainerInspectResult ¶
type ContainerInspectResult struct {
Container container.InspectResponse
Raw json.RawMessage
}
ContainerInspectResult holds the result from the Client.ConfigInspect method.
type ContainerKillOptions ¶
type ContainerKillOptions struct {
// Signal (optional) is the signal to send to the container to (gracefully)
// stop it before forcibly terminating the container with SIGKILL after a
// timeout. If no value is set, the default (SIGKILL) is used.
Signal string `json:",omitempty"`
}
ContainerKillOptions holds options for Client.ContainerKill.
type ContainerKillResult ¶
type ContainerKillResult struct {
}
ContainerKillResult holds the result of Client.ContainerKill,
type ContainerListOptions ¶
type ContainerListOptions struct {
Size bool
All bool
Latest bool
Since string
Before string
Limit int
Filters Filters
}
ContainerListOptions holds parameters to list containers with.
type ContainerListResult ¶
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 ContainerLogsResult ¶
type ContainerLogsResult interface {
io.ReadCloser
}
ContainerLogsResult is the result of a container logs operation.
type ContainerPauseOptions ¶
type ContainerPauseOptions struct {
}
ContainerPauseOptions holds options for Client.ContainerPause.
type ContainerPauseResult ¶
type ContainerPauseResult struct {
}
ContainerPauseResult holds the result of Client.ContainerPause,
type ContainerPruneOptions ¶
type ContainerPruneOptions struct {
Filters Filters
}
ContainerPruneOptions holds parameters to prune containers.
type ContainerPruneResult ¶
type ContainerPruneResult struct {
Report container.PruneReport
}
ContainerPruneResult holds the result from the Client.ContainerPrune method.
type ContainerRemoveOptions ¶
ContainerRemoveOptions holds parameters to remove containers.
type ContainerRemoveResult ¶
type ContainerRemoveResult struct {
}
ContainerRemoveResult holds the result of Client.ContainerRemove,
type ContainerRenameOptions ¶
type ContainerRenameOptions struct {
NewName string
}
ContainerRenameOptions represents the options for renaming a container.
type ContainerRenameResult ¶
type ContainerRenameResult struct {
}
ContainerRenameResult represents the result of a container rename operation.
type ContainerResizeOptions ¶
ContainerResizeOptions holds parameters to resize a TTY. It can be used to resize container TTYs and exec process TTYs too.
type ContainerResizeResult ¶
type ContainerResizeResult struct {
}
ContainerResizeResult holds the result of Client.ContainerResize,
type ContainerRestartOptions ¶
type ContainerRestartOptions 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 no 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"`
}
ContainerRestartOptions holds options for Client.ContainerRestart.
type ContainerRestartResult ¶
type ContainerRestartResult struct {
}
ContainerRestartResult holds the result of Client.ContainerRestart,
type ContainerStartOptions ¶
ContainerStartOptions holds options for Client.ContainerStart.
type ContainerStartResult ¶
type ContainerStartResult struct {
}
ContainerStartResult holds the result of Client.ContainerStart,
type ContainerStatPathOptions ¶
type ContainerStatPathOptions struct {
Path string
}
type ContainerStatPathResult ¶
type ContainerStatsOptions ¶
type ContainerStatsOptions struct {
// Stream enables streaming [container.StatsResponse] results instead
// of collecting a single sample. If enabled, the client remains attached
// until the [ContainerStatsResult.Body] is closed or the context is
// cancelled.
Stream bool
// IncludePreviousSample asks the daemon to collect a prior sample to populate the
// [container.StatsResponse.PreRead] and [container.StatsResponse.PreCPUStats]
// fields.
//
// It set, the daemon collects two samples at a one-second interval before
// returning the result. The first sample populates the PreCPUStats (“previous
// CPU”) field, allowing delta calculations for CPU usage. If false, only
// a single sample is taken and returned immediately, leaving PreRead and
// PreCPUStats empty.
//
// This option has no effect if Stream is enabled. If Stream is enabled,
// [container.StatsResponse.PreCPUStats] is never populated for the first
// record.
IncludePreviousSample bool
}
ContainerStatsOptions holds parameters to retrieve container statistics using the Client.ContainerStats method.
type ContainerStatsResult ¶
type ContainerStatsResult struct {
Body io.ReadCloser
}
ContainerStatsResult holds the result from Client.ContainerStats.
It wraps an io.ReadCloser that provides one or more container.StatsResponse objects for a container, as produced by the "GET /containers/{id}/stats" endpoint. If streaming is disabled, the stream contains a single record.
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 no 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 for Client.ContainerStop.
type ContainerStopResult ¶
type ContainerStopResult struct {
}
ContainerStopResult holds the result of Client.ContainerStop,
type ContainerTopOptions ¶
type ContainerTopOptions struct {
Arguments []string
}
ContainerTopOptions defines options for container top operations.
type ContainerTopResult ¶
ContainerTopResult represents the result of a ContainerTop operation.
type ContainerUnpauseOptions ¶
type ContainerUnpauseOptions struct {
}
ContainerUnpauseOptions holds options for Client.ContainerUnpause.
type ContainerUnpauseResult ¶
type ContainerUnpauseResult struct {
}
ContainerUnpauseResult holds the result of Client.ContainerUnpause,
type ContainerUpdateOptions ¶
type ContainerUpdateOptions struct {
Resources *container.Resources
RestartPolicy *container.RestartPolicy
}
ContainerUpdateOptions holds options for Client.ContainerUpdate.
type ContainerUpdateResult ¶
type ContainerUpdateResult struct {
// Warnings encountered when updating the container.
Warnings []string
}
ContainerUpdateResult is the result from updating a container.
type ContainerWaitOptions ¶
type ContainerWaitOptions struct {
Condition container.WaitCondition
}
ContainerWaitOptions holds options for Client.ContainerWait.
type ContainerWaitResult ¶
type ContainerWaitResult struct {
Result <-chan container.WaitResponse
Error <-chan error
}
ContainerWaitResult defines the result from the Client.ContainerWait method.
type ContainersDiskUsage ¶
type ContainersDiskUsage struct {
// ActiveCount is the number of active containers.
ActiveCount int64
// TotalCount is the total number of containers.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
// TotalSize is the total disk space used by all containers.
TotalSize int64
// Items holds detailed information about each container.
Items []container.Summary
}
ContainersDiskUsage contains disk usage information for containers.
type CopyFromContainerOptions ¶
type CopyFromContainerOptions struct {
SourcePath string
}
type CopyFromContainerResult ¶
type CopyFromContainerResult struct {
Content io.ReadCloser
Stat container.PathStat
}
type CopyToContainerOptions ¶
type CopyToContainerOptions struct {
DestinationPath string
Content io.Reader
AllowOverwriteDirWithFile bool
CopyUIDGID bool
}
CopyToContainerOptions holds information about files to copy into a container
type CopyToContainerResult ¶
type CopyToContainerResult struct{}
type DiskUsageOptions ¶
type DiskUsageOptions struct {
// Containers controls whether container disk usage should be computed.
Containers bool
// Images controls whether image disk usage should be computed.
Images bool
// BuildCache controls whether build cache disk usage should be computed.
BuildCache bool
// Volumes controls whether volume disk usage should be computed.
Volumes bool
// Verbose enables more detailed disk usage information.
Verbose bool
}
DiskUsageOptions holds parameters for Client.DiskUsage operations.
type DiskUsageResult ¶
type DiskUsageResult struct {
// Containers holds container disk usage information.
Containers ContainersDiskUsage
// Images holds image disk usage information.
Images ImagesDiskUsage
// BuildCache holds build cache disk usage information.
BuildCache BuildCacheDiskUsage
// Volumes holds volume disk usage information.
Volumes VolumesDiskUsage
}
DiskUsageResult is the result of Client.DiskUsage operations.
type DistributionAPIClient ¶
type DistributionAPIClient interface {
DistributionInspect(ctx context.Context, image string, options DistributionInspectOptions) (DistributionInspectResult, error)
}
DistributionAPIClient defines API client methods for the registry
type DistributionInspectOptions ¶
type DistributionInspectOptions struct {
EncodedRegistryAuth string
}
DistributionInspectOptions holds options for the DistributionInspect operation.
type DistributionInspectResult ¶
type DistributionInspectResult struct {
registry.DistributionInspect
}
DistributionInspectResult holds the result of the DistributionInspect operation.
type EventsListOptions ¶
EventsListOptions holds parameters to filter events with.
type EventsResult ¶
EventsResult holds the result of an Events query.
type ExecAPIClient ¶
type ExecAPIClient interface {
ExecCreate(ctx context.Context, container string, options ExecCreateOptions) (ExecCreateResult, error)
ExecInspect(ctx context.Context, execID string, options ExecInspectOptions) (ExecInspectResult, error)
ExecResize(ctx context.Context, execID string, options ExecResizeOptions) (ExecResizeResult, error)
ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error)
ExecAttach(ctx context.Context, execID string, options ExecAttachOptions) (ExecAttachResult, error)
}
type ExecAttachOptions ¶
type ExecAttachOptions struct {
// Check if there's a tty
TTY bool
// Terminal size [height, width], unused if TTY == false
ConsoleSize ConsoleSize `json:",omitzero"`
}
ExecAttachOptions holds options for attaching to a container exec.
type ExecAttachResult ¶
type ExecAttachResult struct {
HijackedResponse
}
ExecAttachResult holds the result of attaching to a container exec.
type ExecCreateOptions ¶
type ExecCreateOptions struct {
User string // User that will run the command
Privileged bool // Is the container in privileged mode
TTY bool // Attach standard streams to a tty.
ConsoleSize ConsoleSize // Initial terminal size [height, width], unused if TTY == false
AttachStdin bool // Attach the standard input, makes possible user interaction
AttachStderr bool // Attach the standard error
AttachStdout bool // Attach the standard output
DetachKeys string // Escape keys for detach
Env []string // Environment variables
WorkingDir string // Working directory
Cmd []string // Execution commands and args
}
ExecCreateOptions is a small subset of the Config struct that holds the configuration for the exec feature of docker.
type ExecCreateResult ¶
type ExecCreateResult struct {
ID string
}
ExecCreateResult holds the result of creating a container exec.
type ExecInspectOptions ¶
type ExecInspectOptions struct {
}
ExecInspectOptions holds options for inspecting a container exec.
type ExecInspectResult ¶
ExecInspectResult holds the result of inspecting a container exec.
It provides a subset of the information included in container.ExecInspectResponse.
TODO(thaJeztah): include all fields of container.ExecInspectResponse ?
type ExecResizeOptions ¶
type ExecResizeOptions ContainerResizeOptions
ExecResizeOptions holds options for resizing a container exec TTY.
type ExecResizeResult ¶
type ExecResizeResult struct {
}
ExecResizeResult holds the result of resizing a container exec TTY.
type ExecStartOptions ¶
type ExecStartOptions struct {
// ExecStart will first check if it's detached
Detach bool
// Check if there's a tty
TTY bool
// Terminal size [height, width], unused if TTY == false
ConsoleSize ConsoleSize
}
ExecStartOptions holds options for starting a container exec.
type ExecStartResult ¶
type ExecStartResult struct {
}
ExecStartResult holds the result of starting a container exec.
type Filters ¶
Filters describes a predicate for an API request.
Each entry in the map is a filter term. Each term is evaluated against the set of values. A filter term is satisfied if any one of the values in the set is a match. An item matches the filters when all terms are satisfied.
Like all other map types in Go, the zero value is empty and read-only.
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 {
ImageImport(ctx context.Context, source ImageImportSource, ref string, options ImageImportOptions) (ImageImportResult, error)
ImageList(ctx context.Context, options ImageListOptions) (ImageListResult, error)
ImagePull(ctx context.Context, ref string, options ImagePullOptions) (ImagePullResponse, error)
ImagePush(ctx context.Context, ref string, options ImagePushOptions) (ImagePushResponse, error)
ImageRemove(ctx context.Context, image string, options ImageRemoveOptions) (ImageRemoveResult, error)
ImageTag(ctx context.Context, options ImageTagOptions) (ImageTagResult, error)
ImagePrune(ctx context.Context, opts ImagePruneOptions) (ImagePruneResult, error)
ImageInspect(ctx context.Context, image string, _ ...ImageInspectOption) (ImageInspectResult, error)
ImageHistory(ctx context.Context, image string, _ ...ImageHistoryOption) (ImageHistoryResult, error)
ImageLoad(ctx context.Context, input io.Reader, _ ...ImageLoadOption) (ImageLoadResult, error)
ImageSave(ctx context.Context, images []string, _ ...ImageSaveOption) (ImageSaveResult, error)
}
ImageAPIClient defines API client methods for the images
type ImageBuildAPIClient ¶
type ImageBuildAPIClient interface {
ImageBuild(ctx context.Context, context io.Reader, options ImageBuildOptions) (ImageBuildResult, error)
BuildCachePrune(ctx context.Context, opts BuildCachePruneOptions) (BuildCachePruneResult, error)
BuildCancel(ctx context.Context, id string, opts BuildCancelOptions) (BuildCancelResult, error)
}
ImageBuildAPIClient defines API client methods for building images using the REST API.
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
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
// Platforms selects the platforms to build the image for. Multiple platforms
// can be provided if the daemon supports multi-platform builds.
Platforms []ocispec.Platform
// 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 ¶
ImageBuildOutput defines configuration for exporting a build result
type ImageBuildResult ¶
type ImageBuildResult struct {
Body io.ReadCloser
}
ImageBuildResult holds information returned by a server after building an image.
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 ImageHistoryResult ¶
type ImageHistoryResult struct {
Items []image.HistoryResponseItem
}
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 ocispec.Platform // Platform is the target platform of the image
}
ImageImportOptions holds information to import images from the client host.
type ImageImportResult ¶
type ImageImportResult interface {
io.ReadCloser
}
ImageImportResult holds the response body returned by the daemon for image import.
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 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 ImageInspectResult ¶
type ImageInspectResult struct {
image.InspectResponse
}
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
SharedSize bool
// Manifests indicates whether the image manifests should be returned.
Manifests bool
}
ImageListOptions holds parameters to list images with.
type ImageListResult ¶
ImageListResult holds the result from ImageList.
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.
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 ImageLoadWithQuiet ¶
func ImageLoadWithQuiet(quiet bool) ImageLoadOption
ImageLoadWithQuiet sets the quiet option for the image load operation.
type ImageLoadResult ¶
type ImageLoadResult interface {
io.ReadCloser
}
ImageLoadResult returns information to the client about a load process. It implements io.ReadCloser and must be closed to avoid a resource leak.
type ImagePruneOptions ¶
type ImagePruneOptions struct {
Filters Filters
}
ImagePruneOptions holds parameters to prune images.
type ImagePruneResult ¶
type ImagePruneResult struct {
Report image.PruneReport
}
ImagePruneResult holds the result from the Client.ImagePrune method.
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)
// Platforms selects the platforms to pull. Multiple platforms can be
// specified if the image ia a multi-platform image.
Platforms []ocispec.Platform
}
ImagePullOptions holds information to pull images.
type ImagePullResponse ¶
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 ImagePushResponse ¶
type ImageRemoveOptions ¶
ImageRemoveOptions holds parameters to remove images.
type ImageRemoveResult ¶
type ImageRemoveResult struct {
Items []image.DeleteResponse
}
ImageRemoveResult holds the delete responses returned by the daemon.
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. It produces an error if platforms are already set. This option only has an effect if the input image is a multi-platform image.
type ImageSaveResult ¶
type ImageSaveResult interface {
io.ReadCloser
}
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
Limit int
}
ImageSearchOptions holds parameters to search images with.
type ImageSearchResult ¶
type ImageSearchResult struct {
Items []registry.SearchResult
}
ImageSearchResult wraps results returned by ImageSearch.
type ImageTagOptions ¶
type ImageTagResult ¶
type ImageTagResult struct{}
type ImagesDiskUsage ¶
type ImagesDiskUsage struct {
// ActiveCount is the number of active images.
ActiveCount int64
// TotalCount is the total number of images.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
// TotalSize is the total disk space used by all images.
TotalSize int64
// Items holds detailed information about each image.
Items []image.Summary
}
ImagesDiskUsage contains disk usage information for images.
type InfoOptions ¶
type InfoOptions struct {
}
type NetworkAPIClient ¶
type NetworkAPIClient interface {
NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (NetworkCreateResult, error)
NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (NetworkInspectResult, error)
NetworkList(ctx context.Context, options NetworkListOptions) (NetworkListResult, error)
NetworkRemove(ctx context.Context, network string, options NetworkRemoveOptions) (NetworkRemoveResult, error)
NetworkPrune(ctx context.Context, opts NetworkPruneOptions) (NetworkPruneResult, error)
NetworkConnect(ctx context.Context, network string, options NetworkConnectOptions) (NetworkConnectResult, error)
NetworkDisconnect(ctx context.Context, network string, options NetworkDisconnectOptions) (NetworkDisconnectResult, error)
}
NetworkAPIClient defines API client methods for the networks
type NetworkConnectOptions ¶
type NetworkConnectOptions struct {
Container string
EndpointConfig *network.EndpointSettings
}
NetworkConnectOptions represents the data to be used to connect a container to the network.
type NetworkConnectResult ¶
type NetworkConnectResult struct {
}
NetworkConnectResult represents the result of a NetworkConnect operation.
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 string // 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 NetworkCreateResult ¶
NetworkCreateResult represents the result of a network create operation.
type NetworkDisconnectOptions ¶
NetworkDisconnectOptions represents the data to be used to disconnect a container from the network.
type NetworkDisconnectResult ¶
type NetworkDisconnectResult struct {
}
NetworkDisconnectResult represents the result of a NetworkDisconnect operation.
type NetworkInspectOptions ¶
NetworkInspectOptions holds parameters to inspect network.
type NetworkInspectResult ¶
type NetworkInspectResult struct {
Network network.Inspect
Raw json.RawMessage
}
NetworkInspectResult contains the result of a network inspection.
type NetworkListOptions ¶
type NetworkListOptions struct {
Filters Filters
}
NetworkListOptions holds parameters to filter the list of networks with.
type NetworkListResult ¶
NetworkListResult holds the result from the Client.NetworkList method.
type NetworkPruneOptions ¶
type NetworkPruneOptions struct {
Filters Filters
}
NetworkPruneOptions holds parameters to prune networks.
type NetworkPruneResult ¶
type NetworkPruneResult struct {
Report network.PruneReport
}
NetworkPruneResult holds the result from the Client.NetworkPrune method.
type NetworkRemoveOptions ¶
type NetworkRemoveOptions struct {
}
NetworkRemoveOptions specifies options for removing a network.
type NetworkRemoveResult ¶
type NetworkRemoveResult struct {
}
NetworkRemoveResult represents the result of a network removal operation.
type NodeAPIClient ¶
type NodeAPIClient interface {
NodeInspect(ctx context.Context, nodeID string, options NodeInspectOptions) (NodeInspectResult, error)
NodeList(ctx context.Context, options NodeListOptions) (NodeListResult, error)
NodeUpdate(ctx context.Context, nodeID string, options NodeUpdateOptions) (NodeUpdateResult, error)
NodeRemove(ctx context.Context, nodeID string, options NodeRemoveOptions) (NodeRemoveResult, error)
}
NodeAPIClient defines API client methods for the nodes
type NodeInspectOptions ¶
type NodeInspectOptions struct{}
NodeInspectOptions holds parameters to inspect nodes with.
type NodeInspectResult ¶
type NodeInspectResult struct {
Node swarm.Node
Raw json.RawMessage
}
type NodeListOptions ¶
type NodeListOptions struct {
Filters Filters
}
NodeListOptions holds parameters to list nodes with.
type NodeListResult ¶
type NodeRemoveOptions ¶
type NodeRemoveOptions struct {
Force bool
}
NodeRemoveOptions holds parameters to remove nodes with.
type NodeRemoveResult ¶
type NodeRemoveResult struct{}
type NodeUpdateOptions ¶
NodeUpdateOptions holds parameters to update nodes with.
type NodeUpdateResult ¶
type NodeUpdateResult struct{}
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 ¶
WithHTTPClient overrides the client's HTTP client with the specified one.
func WithHTTPHeaders ¶
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 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 ¶
WithScheme overrides the client scheme with the specified one.
func WithTLSClientConfig ¶
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 ¶
WithTimeout configures the time limit for requests made by the HTTP client.
func WithTraceOptions ¶
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 ¶
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 ¶
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 PingOptions ¶
type PingOptions struct {
// 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 lowest supported API version.
NegotiateAPIVersion bool
// ForceNegotiate forces the client to re-negotiate the API version, even if
// API-version negotiation already happened. This option cannot be
// used if the client is configured with a fixed version using (using
// [WithVersion] or [WithVersionFromEnv]).
//
// This option has no effect if NegotiateAPIVersion is not set.
ForceNegotiate bool
}
PingOptions holds options for client.Ping.
type PingResult ¶
type PingResult struct {
APIVersion string
OSType string
Experimental bool
BuilderVersion build.BuilderVersion
// SwarmStatus provides information about the current swarm status of the
// engine, obtained from the "Swarm" header in the API response.
//
// It can be a nil struct if the API version does not provide this header
// in the ping response, or if an error occurred, in which case the client
// should use other ways to get the current swarm status, such as the /swarm
// endpoint.
SwarmStatus *SwarmStatus
}
PingResult holds the result of a Client.Ping API call.
type PlatformInfo ¶
type PlatformInfo struct {
// Name is the name of the platform (for example, "Docker Engine - Community",
// or "Docker Desktop 4.49.0 (208003)")
Name string
}
PlatformInfo holds information about the platform (product name) the server is running on.
type PluginAPIClient ¶
type PluginAPIClient interface {
PluginCreate(ctx context.Context, createContext io.Reader, options PluginCreateOptions) (PluginCreateResult, error)
PluginInstall(ctx context.Context, name string, options PluginInstallOptions) (PluginInstallResult, error)
PluginInspect(ctx context.Context, name string, options PluginInspectOptions) (PluginInspectResult, error)
PluginList(ctx context.Context, options PluginListOptions) (PluginListResult, error)
PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) (PluginRemoveResult, error)
PluginEnable(ctx context.Context, name string, options PluginEnableOptions) (PluginEnableResult, error)
PluginDisable(ctx context.Context, name string, options PluginDisableOptions) (PluginDisableResult, error)
PluginUpgrade(ctx context.Context, name string, options PluginUpgradeOptions) (PluginUpgradeResult, error)
PluginPush(ctx context.Context, name string, options PluginPushOptions) (PluginPushResult, error)
PluginSet(ctx context.Context, name string, options PluginSetOptions) (PluginSetResult, error)
}
PluginAPIClient defines API client methods for the plugins
type PluginCreateOptions ¶
type PluginCreateOptions struct {
RepoName string
}
PluginCreateOptions hold all options to plugin create.
type PluginCreateResult ¶
type PluginCreateResult struct {
}
PluginCreateResult represents the result of a plugin create operation.
type PluginDisableOptions ¶
type PluginDisableOptions struct {
Force bool
}
PluginDisableOptions holds parameters to disable plugins.
type PluginDisableResult ¶
type PluginDisableResult struct {
}
PluginDisableResult represents the result of a plugin disable operation.
type PluginEnableOptions ¶
type PluginEnableOptions struct {
Timeout int
}
PluginEnableOptions holds parameters to enable plugins.
type PluginEnableResult ¶
type PluginEnableResult struct {
}
PluginEnableResult represents the result of a plugin enable operation.
type PluginInspectOptions ¶
type PluginInspectOptions struct {
}
PluginInspectOptions holds parameters to inspect a plugin.
type PluginInspectResult ¶
type PluginInspectResult struct {
Plugin plugin.Plugin
Raw json.RawMessage
}
PluginInspectResult holds the result from the Client.PluginInspect method.
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 PluginInstallResult ¶
type PluginInstallResult struct {
io.ReadCloser
}
PluginInstallResult holds the result of a plugin install operation. It is an io.ReadCloser from which the caller can read installation progress or result.
type PluginListOptions ¶
type PluginListOptions struct {
Filters Filters
}
PluginListOptions holds parameters to list plugins.
type PluginListResult ¶
PluginListResult represents the result of a plugin list operation.
type PluginPushOptions ¶
type PluginPushOptions struct {
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
}
PluginPushOptions holds parameters to push a plugin.
type PluginPushResult ¶
type PluginPushResult struct {
io.ReadCloser
}
PluginPushResult is the result of a plugin push operation
type PluginRemoveOptions ¶
type PluginRemoveOptions struct {
Force bool
}
PluginRemoveOptions holds parameters to remove plugins.
type PluginRemoveResult ¶
type PluginRemoveResult struct {
}
PluginRemoveResult represents the result of a plugin removal.
type PluginSetOptions ¶
type PluginSetOptions struct {
Args []string
}
PluginSetOptions defines options for modifying a plugin's settings.
type PluginSetResult ¶
type PluginSetResult struct {
}
PluginSetResult represents the result of a plugin set operation.
type PluginUpgradeOptions ¶
type PluginUpgradeOptions 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
}
PluginUpgradeOptions holds parameters to upgrade a plugin.
type PluginUpgradeResult ¶
type PluginUpgradeResult io.ReadCloser
PluginUpgradeResult holds the result of a plugin upgrade operation.
type RegistryLoginOptions ¶
type RegistryLoginResult ¶
type RegistryLoginResult struct {
Auth registry.AuthResponse
}
RegistryLoginResult holds the result of a RegistryLogin query.
type RegistrySearchClient ¶
type RegistrySearchClient interface {
ImageSearch(ctx context.Context, term string, options ImageSearchOptions) (ImageSearchResult, error)
}
type SecretAPIClient ¶
type SecretAPIClient interface {
SecretCreate(ctx context.Context, options SecretCreateOptions) (SecretCreateResult, error)
SecretInspect(ctx context.Context, id string, options SecretInspectOptions) (SecretInspectResult, error)
SecretList(ctx context.Context, options SecretListOptions) (SecretListResult, error)
SecretUpdate(ctx context.Context, id string, options SecretUpdateOptions) (SecretUpdateResult, error)
SecretRemove(ctx context.Context, id string, options SecretRemoveOptions) (SecretRemoveResult, error)
}
SecretAPIClient defines API client methods for secrets
type SecretCreateOptions ¶
type SecretCreateOptions struct {
Spec swarm.SecretSpec
}
SecretCreateOptions holds options for creating a secret.
type SecretCreateResult ¶
type SecretCreateResult struct {
ID string
}
SecretCreateResult holds the result from the Client.SecretCreate method.
type SecretInspectOptions ¶
type SecretInspectOptions struct {
}
SecretInspectOptions holds options for inspecting a secret.
type SecretInspectResult ¶
type SecretInspectResult struct {
Secret swarm.Secret
Raw json.RawMessage
}
SecretInspectResult holds the result from the Client.SecretInspect. method.
type SecretListOptions ¶
type SecretListOptions struct {
Filters Filters
}
SecretListOptions holds parameters to list secrets
type SecretListResult ¶
SecretListResult holds the result from the client.SecretList method.
type SecretRemoveOptions ¶
type SecretRemoveOptions struct {
}
type SecretRemoveResult ¶
type SecretRemoveResult struct {
}
type SecretUpdateOptions ¶
type SecretUpdateOptions struct {
Version swarm.Version
Spec swarm.SecretSpec
}
SecretUpdateOptions holds options for updating a secret.
type SecretUpdateResult ¶
type SecretUpdateResult struct{}
type ServerVersionOptions ¶
type ServerVersionOptions struct {
}
ServerVersionOptions specifies options for the server version request.
type ServerVersionResult ¶
type ServerVersionResult struct {
// Platform is the platform (product name) the server is running on.
Platform PlatformInfo
// Version is the version of the daemon.
Version string
// APIVersion is the highest API version supported by the server.
APIVersion string
// MinAPIVersion is the minimum API version the server supports.
MinAPIVersion string
// Os is the operating system the server runs on.
Os string
// Arch is the hardware architecture the server runs on.
Arch string
// Experimental indicates that the daemon runs with experimental
// features enabled.
//
// Deprecated: this field will be removed in the next version.
Experimental bool
// Components contains version information for the components making
// up the server. Information in this field is for informational
// purposes, and not part of the API contract.
Components []system.ComponentVersion
}
ServerVersionResult contains information about the Docker server host.
type ServiceAPIClient ¶
type ServiceAPIClient interface {
ServiceCreate(ctx context.Context, options ServiceCreateOptions) (ServiceCreateResult, error)
ServiceInspect(ctx context.Context, serviceID string, options ServiceInspectOptions) (ServiceInspectResult, error)
ServiceList(ctx context.Context, options ServiceListOptions) (ServiceListResult, error)
ServiceUpdate(ctx context.Context, serviceID string, options ServiceUpdateOptions) (ServiceUpdateResult, error)
ServiceRemove(ctx context.Context, serviceID string, options ServiceRemoveOptions) (ServiceRemoveResult, error)
ServiceLogs(ctx context.Context, serviceID string, options ServiceLogsOptions) (ServiceLogsResult, error)
}
ServiceAPIClient defines API client methods for the services
type ServiceCreateOptions ¶
type ServiceCreateOptions struct {
Spec swarm.ServiceSpec
// 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 ServiceCreateResult ¶
type ServiceCreateResult struct {
// ID is the ID of the created service.
ID string
// Warnings is a list of warnings that occurred during service creation.
Warnings []string
}
ServiceCreateResult represents the result of creating a service.
type ServiceInspectOptions ¶
type ServiceInspectOptions struct {
InsertDefaults bool
}
ServiceInspectOptions holds parameters related to the service inspect operation.
type ServiceInspectResult ¶
type ServiceInspectResult struct {
Service swarm.Service
Raw json.RawMessage
}
ServiceInspectResult represents the result of a service inspect operation.
type ServiceListOptions ¶
type ServiceListOptions struct {
Filters Filters
// 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 ServiceListResult ¶
ServiceListResult represents the result of a service list operation.
type ServiceLogsOptions ¶
type ServiceLogsOptions struct {
ShowStdout bool
ShowStderr bool
Since string
Until string
Timestamps bool
Follow bool
Tail string
Details bool
}
ServiceLogsOptions holds parameters to filter logs with.
type ServiceLogsResult ¶
type ServiceLogsResult interface {
io.ReadCloser
}
ServiceLogsResult holds the result of a service logs operation. It implements io.ReadCloser. It's up to the caller to close the stream.
type ServiceRemoveOptions ¶
type ServiceRemoveOptions struct {
}
ServiceRemoveOptions contains options for removing a service.
type ServiceRemoveResult ¶
type ServiceRemoveResult struct {
}
ServiceRemoveResult contains the result of removing a service.
type ServiceUpdateOptions ¶
type ServiceUpdateOptions struct {
Version swarm.Version
Spec swarm.ServiceSpec
// 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 swarm.RegistryAuthSource
// 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 ServiceUpdateResult ¶
type ServiceUpdateResult struct {
// Warnings contains any warnings that occurred during the update.
Warnings []string
}
ServiceUpdateResult represents the result of a service update.
type SwarmAPIClient ¶
type SwarmAPIClient interface {
SwarmInit(ctx context.Context, options SwarmInitOptions) (SwarmInitResult, error)
SwarmJoin(ctx context.Context, options SwarmJoinOptions) (SwarmJoinResult, error)
SwarmInspect(ctx context.Context, options SwarmInspectOptions) (SwarmInspectResult, error)
SwarmUpdate(ctx context.Context, options SwarmUpdateOptions) (SwarmUpdateResult, error)
SwarmLeave(ctx context.Context, options SwarmLeaveOptions) (SwarmLeaveResult, error)
SwarmGetUnlockKey(ctx context.Context) (SwarmGetUnlockKeyResult, error)
SwarmUnlock(ctx context.Context, options SwarmUnlockOptions) (SwarmUnlockResult, error)
}
SwarmAPIClient defines API client methods for the swarm
type SwarmGetUnlockKeyResult ¶
type SwarmGetUnlockKeyResult struct {
Key string
}
SwarmGetUnlockKeyResult contains the swarm unlock key.
type SwarmInitOptions ¶
type SwarmInitOptions struct {
ListenAddr string
AdvertiseAddr string
DataPathAddr string
DataPathPort uint32
ForceNewCluster bool
Spec swarm.Spec
AutoLockManagers bool
Availability swarm.NodeAvailability
DefaultAddrPool []netip.Prefix
SubnetSize uint32
}
SwarmInitOptions contains options for initializing a new swarm.
type SwarmInitResult ¶
type SwarmInitResult struct {
NodeID string
}
SwarmInitResult contains the result of a SwarmInit operation.
type SwarmInspectOptions ¶
type SwarmInspectOptions struct {
}
SwarmInspectOptions holds options for inspecting a swarm.
type SwarmInspectResult ¶
SwarmInspectResult represents the result of a SwarmInspect operation.
type SwarmJoinOptions ¶
type SwarmJoinOptions struct {
ListenAddr string
AdvertiseAddr string
DataPathAddr string
RemoteAddrs []string
JoinToken string // accept by secret
Availability swarm.NodeAvailability
}
SwarmJoinOptions specifies options for joining a swarm.
type SwarmJoinResult ¶
type SwarmJoinResult struct {
}
SwarmJoinResult contains the result of joining a swarm.
type SwarmLeaveOptions ¶
type SwarmLeaveOptions struct {
Force bool
}
SwarmLeaveOptions contains options for leaving a swarm.
type SwarmLeaveResult ¶
type SwarmLeaveResult struct{}
SwarmLeaveResult represents the result of a SwarmLeave operation.
type SwarmManagementAPIClient ¶
type SwarmManagementAPIClient interface {
SwarmAPIClient
NodeAPIClient
ServiceAPIClient
TaskAPIClient
SecretAPIClient
ConfigAPIClient
}
SwarmManagementAPIClient defines all methods for managing Swarm-specific objects.
type SwarmStatus ¶
type SwarmStatus struct {
// NodeState represents the state of the node.
NodeState swarm.LocalNodeState
// ControlAvailable indicates if the node is a swarm manager.
ControlAvailable bool
}
SwarmStatus provides information about the current swarm status and role, obtained from the "Swarm" header in the API response.
type SwarmUnlockOptions ¶
type SwarmUnlockOptions struct {
Key string
}
SwarmUnlockOptions specifies options for unlocking a swarm.
type SwarmUnlockResult ¶
type SwarmUnlockResult struct{}
SwarmUnlockResult represents the result of unlocking a swarm.
type SwarmUpdateOptions ¶
type SwarmUpdateOptions struct {
Version swarm.Version
Spec swarm.Spec
RotateWorkerToken bool
RotateManagerToken bool
RotateManagerUnlockKey bool
}
SwarmUpdateOptions contains options for updating a swarm.
type SwarmUpdateResult ¶
type SwarmUpdateResult struct{}
SwarmUpdateResult represents the result of a SwarmUpdate operation.
type SystemAPIClient ¶
type SystemAPIClient interface {
Events(ctx context.Context, options EventsListOptions) EventsResult
Info(ctx context.Context, options InfoOptions) (SystemInfoResult, error)
RegistryLogin(ctx context.Context, auth RegistryLoginOptions) (RegistryLoginResult, error)
DiskUsage(ctx context.Context, options DiskUsageOptions) (DiskUsageResult, error)
Ping(ctx context.Context, options PingOptions) (PingResult, error)
}
SystemAPIClient defines API client methods for the system
type SystemInfoResult ¶
type TaskAPIClient ¶
type TaskAPIClient interface {
TaskInspect(ctx context.Context, taskID string, options TaskInspectOptions) (TaskInspectResult, error)
TaskList(ctx context.Context, options TaskListOptions) (TaskListResult, error)
TaskLogs(ctx context.Context, taskID string, options TaskLogsOptions) (TaskLogsResult, error)
}
TaskAPIClient defines API client methods to manage swarm tasks.
type TaskInspectOptions ¶
type TaskInspectOptions struct {
}
TaskInspectOptions contains options for inspecting a task.
type TaskInspectResult ¶
type TaskInspectResult struct {
Task swarm.Task
Raw json.RawMessage
}
TaskInspectResult contains the result of a task inspection.
type TaskListOptions ¶
type TaskListOptions struct {
Filters Filters
}
TaskListOptions holds parameters to list tasks with.
type TaskListResult ¶
TaskListResult contains the result of a task list operation.
type TaskLogsOptions ¶
type TaskLogsOptions struct {
ShowStdout bool
ShowStderr bool
Since string
Until string
Timestamps bool
Follow bool
Tail string
Details bool
}
TaskLogsOptions holds parameters to filter logs with.
type TaskLogsResult ¶
type TaskLogsResult interface {
io.ReadCloser
}
TaskLogsResult holds the result of a task logs operation. It implements io.ReadCloser.
type VolumeAPIClient ¶
type VolumeAPIClient interface {
VolumeCreate(ctx context.Context, options VolumeCreateOptions) (VolumeCreateResult, error)
VolumeInspect(ctx context.Context, volumeID string, options VolumeInspectOptions) (VolumeInspectResult, error)
VolumeList(ctx context.Context, options VolumeListOptions) (VolumeListResult, error)
VolumeUpdate(ctx context.Context, volumeID string, options VolumeUpdateOptions) (VolumeUpdateResult, error)
VolumeRemove(ctx context.Context, volumeID string, options VolumeRemoveOptions) (VolumeRemoveResult, error)
VolumePrune(ctx context.Context, options VolumePruneOptions) (VolumePruneResult, error)
}
VolumeAPIClient defines API client methods for the volumes
type VolumeCreateOptions ¶
type VolumeCreateOptions struct {
Name string
Driver string
DriverOpts map[string]string
Labels map[string]string
ClusterVolumeSpec *volume.ClusterVolumeSpec
}
VolumeCreateOptions specifies the options to create a volume.
type VolumeCreateResult ¶
VolumeCreateResult is the result of a volume creation.
type VolumeInspectOptions ¶
type VolumeInspectOptions struct {
}
VolumeInspectOptions holds options for inspecting a volume.
type VolumeInspectResult ¶
type VolumeInspectResult struct {
Volume volume.Volume
Raw json.RawMessage
}
VolumeInspectResult holds the result from the Client.VolumeInspect method.
type VolumeListOptions ¶
type VolumeListOptions struct {
Filters Filters
}
VolumeListOptions holds parameters to list volumes.
type VolumeListResult ¶
type VolumeListResult struct {
// List of volumes.
Items []volume.Volume
// Warnings that occurred when fetching the list of volumes.
Warnings []string
}
VolumeListResult holds the result from the Client.VolumeList method.
type VolumePruneOptions ¶
type VolumePruneOptions struct {
// All controls whether named volumes should also be pruned. By
// default, only anonymous volumes are pruned.
All bool
// Filters to apply when pruning.
Filters Filters
}
VolumePruneOptions holds parameters to prune volumes.
type VolumePruneResult ¶
type VolumePruneResult struct {
Report volume.PruneReport
}
VolumePruneResult holds the result from the Client.VolumePrune method.
type VolumeRemoveOptions ¶
type VolumeRemoveOptions struct {
// Force the removal of the volume
Force bool
}
VolumeRemoveOptions holds options for Client.VolumeRemove.
type VolumeRemoveResult ¶
type VolumeRemoveResult struct {
}
VolumeRemoveResult holds the result of Client.VolumeRemove,
type VolumeUpdateOptions ¶
type VolumeUpdateOptions struct {
Version swarm.Version
// Spec is the ClusterVolumeSpec to update the volume to.
Spec *volume.ClusterVolumeSpec `json:"Spec,omitempty"`
}
VolumeUpdateOptions holds options for Client.VolumeUpdate.
type VolumeUpdateResult ¶
type VolumeUpdateResult struct {
}
VolumeUpdateResult holds the result of Client.VolumeUpdate,
type VolumesDiskUsage ¶
type VolumesDiskUsage struct {
// ActiveCount is the number of active volumes.
ActiveCount int64
// TotalCount is the total number of volumes.
TotalCount int64
// Reclaimable is the amount of disk space that can be reclaimed.
Reclaimable int64
// TotalSize is the total disk space used by all volumes.
TotalSize int64
// Items holds detailed information about each volume.
Items []volume.Volume
}
VolumesDiskUsage contains disk usage information for volumes.
Source Files
¶
- auth.go
- build_cancel.go
- build_prune.go
- checkpoint_create.go
- checkpoint_list.go
- checkpoint_remove.go
- client.go
- client_interfaces.go
- client_unix.go
- config_create.go
- config_inspect.go
- config_list.go
- config_remove.go
- config_update.go
- container_attach.go
- container_commit.go
- container_copy.go
- container_create.go
- container_create_opts.go
- container_diff.go
- container_diff_opts.go
- container_exec.go
- container_export.go
- container_inspect.go
- container_kill.go
- container_list.go
- container_logs.go
- container_pause.go
- container_prune.go
- container_remove.go
- container_rename.go
- container_resize.go
- container_restart.go
- container_start.go
- container_stats.go
- container_stop.go
- container_top.go
- container_unpause.go
- container_update.go
- container_wait.go
- distribution_inspect.go
- envvars.go
- errors.go
- filters.go
- hijack.go
- image_build.go
- image_build_opts.go
- image_history.go
- image_history_opts.go
- image_import.go
- image_import_opts.go
- image_inspect.go
- image_inspect_opts.go
- image_list.go
- image_list_opts.go
- image_load.go
- image_load_opts.go
- image_prune.go
- image_pull.go
- image_pull_opts.go
- image_push.go
- image_push_opts.go
- image_remove.go
- image_remove_opts.go
- image_save.go
- image_save_opts.go
- image_search.go
- image_search_opts.go
- image_tag.go
- login.go
- network_connect.go
- network_create.go
- network_disconnect.go
- network_inspect.go
- network_inspect_opts.go
- network_list.go
- network_list_opts.go
- network_prune.go
- network_remove.go
- node_inspect.go
- node_list.go
- node_remove.go
- node_update.go
- options.go
- ping.go
- plugin_create.go
- plugin_disable.go
- plugin_enable.go
- plugin_inspect.go
- plugin_install.go
- plugin_list.go
- plugin_push.go
- plugin_remove.go
- plugin_set.go
- plugin_upgrade.go
- request.go
- secret_create.go
- secret_inspect.go
- secret_list.go
- secret_remove.go
- secret_update.go
- service_create.go
- service_inspect.go
- service_list.go
- service_logs.go
- service_remove.go
- service_update.go
- swarm_get_unlock_key.go
- swarm_init.go
- swarm_inspect.go
- swarm_join.go
- swarm_leave.go
- swarm_unlock.go
- swarm_update.go
- system_disk_usage.go
- system_events.go
- system_info.go
- task_inspect.go
- task_list.go
- task_logs.go
- utils.go
- version.go
- volume_create.go
- volume_inspect.go
- volume_list.go
- volume_prune.go
- volume_remove.go
- volume_update.go
Directories
¶
| Path | Synopsis |
|---|---|
|
pkg
|
|
|
streamformatter
Package streamformatter provides helper functions to format a stream.
|
Package streamformatter provides helper functions to format a stream. |
|
stringid
Package stringid provides helper functions for dealing with string identifiers.
|
Package stringid provides helper functions for dealing with string identifiers. |