package
0.0.0-20241112080837-97b903613cec
Repository: https://github.com/deepin-community/docker.io.git
Documentation: pkg.go.dev

# README

Go client for the Docker Engine API

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

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

package main

import (
	"context"
	"fmt"

	"github.com/docker/docker/api/types/container"
	"github.com/docker/docker/client"
)

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

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

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

Full documentation is available on pkg.go.dev.

# Packages

No description provided by the author

# Functions

CheckRedirect specifies the policy for dealing with redirect responses.
ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed.
FromEnv configures the client with values from environment variables.
IsErrConnectionFailed returns true if the error is caused by connection failed.
IsErrNotFound returns true if the error is a NotFound error, which is returned by the API when some object is not found.
NewClient initializes a new API client for the given host and API version.
NewClientWithOpts initializes a new API client with a default HTTPClient, and default API host and version.
NewEnvClient initializes a new API client based on environment variables.
ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL.
WithAPIVersionNegotiation enables automatic API version negotiation for the client.
WithDialContext applies the dialer to the client transport.
WithHost overrides the client host with the specified one.
WithHostFromEnv overrides the client host with the host specified in the DOCKER_HOST ([EnvOverrideHost]) environment variable.
WithHTTPClient overrides the client's HTTP client with the specified one.
WithHTTPHeaders appends custom HTTP headers to the client's default headers.
WithScheme overrides the client scheme with the specified one.
WithTimeout configures the time limit for requests made by the HTTP client.
WithTLSClientConfig applies a TLS config to the client transport.
WithTLSClientConfigFromEnv configures the client's TLS settings with the settings in the DOCKER_CERT_PATH ([EnvOverrideCertPath]) and DOCKER_TLS_VERIFY ([EnvTLSVerify]) environment variables.
WithTraceProvider sets the trace provider for the client.
WithUserAgent configures the User-Agent header to use for HTTP requests.
WithVersion overrides the client version with the specified one.
WithVersionFromEnv overrides the client version with the version specified in the DOCKER_API_VERSION ([EnvOverrideAPIVersion]) environment variable.

# Constants

DefaultDockerHost defines OS-specific default host if the DOCKER_HOST (EnvOverrideHost) environment variable is unset or empty.
DummyHost is a hostname used for local communication.
EnvOverrideAPIVersion is the name of the environment variable that can be used to override the API version to use.
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.
EnvOverrideHost is the name of the environment variable that can be used to override the default host to connect to (DefaultDockerHost).
EnvTLSVerify is the name of the environment variable that can be used to enable or disable TLS certificate verification.

# Variables

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

# Structs

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

# Interfaces

APIClient is an interface that clients that talk with a docker server must implement.
CheckpointAPIClient defines API client methods for the checkpoints.
CommonAPIClient is the common methods between stable and experimental versions of APIClient.
ConfigAPIClient defines API client methods for configs.
ContainerAPIClient defines API client methods for the containers.
DistributionAPIClient defines API client methods for the registry.
ImageAPIClient defines API client methods for the images.
NetworkAPIClient defines API client methods for the networks.
NodeAPIClient defines API client methods for the nodes.
PluginAPIClient defines API client methods for the plugins.
SecretAPIClient defines API client methods for secrets.
ServiceAPIClient defines API client methods for the services.
SwarmAPIClient defines API client methods for the swarm.
SystemAPIClient defines API client methods for the system.
VolumeAPIClient defines API client methods for the volumes.

# Type aliases

Opt is a configuration option to initialize a [Client].