package
17.12.1-ce-rc2+incompatible
Repository: https://github.com/nobidev/docker-cli.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 running containers (the equivalent of docker ps
):
package main
import (
"context"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
func main() {
cli, err := client.NewEnvClient()
if err != nil {
panic(err)
}
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
if err != nil {
panic(err)
}
for _, container := range containers {
fmt.Printf("%s %s\n", container.ID[:10], container.Image)
}
}
# Functions
CheckRedirect specifies the policy for dealing with redirect responses: If the request is non-GET return `ErrRedirect`.
ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed.
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.
IsErrNotImplemented returns true if the error is a NotImplemented error.
IsErrPluginPermissionDenied returns true if the error is caused when a user denies a plugin's permissions.
IsErrUnauthorized returns true if the error is caused when a remote registry authentication fails.
NewClient initializes a new API client for the given host and API version.
NewEnvClient initializes a new API client based on environment variables.
ParseHost parses a url string, validates the strings is a host url, and returns the parsed host as: protocol, address, and base path Deprecated: use ParseHostURL.
ParseHostURL parses a url string, validates the string is a host url, and returns the parsed URL.
# Constants
DefaultDockerHost defines os specific default if DOCKER_HOST is unset.
# Variables
ErrRedirect is the error returned by checkRedirect when the request is non-GET.
# 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.