package
1.13.1
Repository: https://github.com/react-vue-devel/moby.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)
	}
}

Full documentation is available on GoDoc.

# Functions

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.
IsErrContainerNotFound returns true if the error is caused when a container is not found in the docker host.
IsErrImageNotFound returns true if the error is caused when an image is not found in the docker host.
IsErrNetworkNotFound returns true if the error is caused when a network is not found in the docker host.
IsErrNodeNotFound returns true if the error is caused when a node is not found.
IsErrNotFound returns true if the error is caused with an object (image, container, network, volume, …) is not found in the docker host.
IsErrPluginNotFound returns true if the error is caused when a plugin is not found in the docker host.
IsErrPluginPermissionDenied returns true if the error is caused when a user denies a plugin's permissions.
IsErrSecretNotFound returns true if the error is caused when a secret is not found.
IsErrServiceNotFound returns true if the error is caused when a service is not found.
IsErrTaskNotFound returns true if the error is caused when a task is not found.
IsErrUnauthorized returns true if the error is caused when a remote registry authentication fails.
IsErrVolumeNotFound returns true if the error is caused when a volume is not found in the docker host.
NewClient initializes a new API client for the given host and API version.
NewEnvClient initializes a new API client based on environment variables.
ParseHost verifies that the given host strings is valid.

# Constants

DefaultDockerHost defines os specific default if DOCKER_HOST is unset.
DefaultVersion is the version of the current stable API.

# 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.
ContainerAPIClient defines API client methods for the containers.
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.