client

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2016 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConnectionFailed = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?")

ErrConnectionFailed is a error raised when the connection between the client and the server failed.

Functions

func IsErrContainerNotFound

func IsErrContainerNotFound(err error) bool

IsErrContainerNotFound returns true if the error is caused when a container is not found in the docker host.

func IsErrImageNotFound

func IsErrImageNotFound(err error) bool

IsErrImageNotFound returns true if the error is caused when an image is not found in the docker host.

func IsErrNetworkNotFound

func IsErrNetworkNotFound(err error) bool

IsErrNetworkNotFound returns true if the error is caused when a network is not found in the docker host.

func IsErrUnauthorized

func IsErrUnauthorized(err error) bool

IsErrUnauthorized returns true if the error is caused when an the remote registry authentication fails

func IsErrVolumeNotFound

func IsErrVolumeNotFound(err error) bool

IsErrVolumeNotFound returns true if the error is caused when a volume is not found in the docker host.

Types

type APIClient added in v0.1.2

type APIClient interface {
	ClientVersion() string
	ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error)
	ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
	ContainerCreate(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error)
	ContainerDiff(containerID string) ([]types.ContainerChange, error)
	ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error)
	ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error)
	ContainerExecInspect(execID string) (types.ContainerExecInspect, error)
	ContainerExecResize(options types.ResizeOptions) error
	ContainerExecStart(execID string, config types.ExecStartCheck) error
	ContainerExport(containerID string) (io.ReadCloser, error)
	ContainerInspect(containerID string) (types.ContainerJSON, error)
	ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error)
	ContainerKill(containerID, signal string) error
	ContainerList(options types.ContainerListOptions) ([]types.Container, error)
	ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error)
	ContainerPause(containerID string) error
	ContainerRemove(options types.ContainerRemoveOptions) error
	ContainerRename(containerID, newContainerName string) error
	ContainerResize(options types.ResizeOptions) error
	ContainerRestart(containerID string, timeout int) error
	ContainerStatPath(containerID, path string) (types.ContainerPathStat, error)
	ContainerStats(containerID string, stream bool) (io.ReadCloser, error)
	ContainerStart(containerID string) error
	ContainerStop(containerID string, timeout int) error
	ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error)
	ContainerUnpause(containerID string) error
	ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error
	ContainerWait(containerID string) (int, error)
	CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
	CopyToContainer(options types.CopyToContainerOptions) error
	Events(options types.EventsOptions) (io.ReadCloser, error)
	ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error)
	ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error)
	ImageHistory(imageID string) ([]types.ImageHistory, error)
	ImageImport(options types.ImageImportOptions) (io.ReadCloser, error)
	ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error)
	ImageList(options types.ImageListOptions) ([]types.Image, error)
	ImageLoad(input io.Reader) (types.ImageLoadResponse, error)
	ImagePull(options types.ImagePullOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error)
	ImagePush(options types.ImagePushOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error)
	ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error)
	ImageSearch(options types.ImageSearchOptions, privilegeFunc RequestPrivilegeFunc) ([]registry.SearchResult, error)
	ImageSave(imageIDs []string) (io.ReadCloser, error)
	ImageTag(options types.ImageTagOptions) error
	Info() (types.Info, error)
	NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error
	NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error)
	NetworkDisconnect(networkID, containerID string, force bool) error
	NetworkInspect(networkID string) (types.NetworkResource, error)
	NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error)
	NetworkRemove(networkID string) error
	RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error)
	ServerVersion() (types.Version, error)
	VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error)
	VolumeInspect(volumeID string) (types.Volume, error)
	VolumeList(filter filters.Args) (types.VolumesListResponse, error)
	VolumeRemove(volumeID string) error
}

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

type Client

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

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

func NewClient

func NewClient(host string, version string, transport *http.Transport, httpHeaders map[string]string) (*Client, error)

NewClient initializes a new API client for the given host and API version. It won't send any version information if the version number is empty. It uses the transport to create a new http client. It also initializes the custom http headers to add to each request.

func NewEnvClient

func NewEnvClient() (*Client, error)

NewEnvClient initializes a new API client based on environment variables. Use DOCKER_HOST to set the url to the docker server. Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest. Use DOCKER_CERT_PATH to load the tls certificates from. Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.

func (*Client) ClientVersion

func (cli *Client) ClientVersion() string

ClientVersion returns the version string associated with this instance of the Client. Note that this value can be changed via the DOCKER_API_VERSION env var.

func (*Client) ContainerAttach

func (cli *Client) ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error)

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

func (*Client) ContainerCommit

func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)

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

func (*Client) ContainerCreate

func (cli *Client) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error)

ContainerCreate creates a new container based in the given configuration. It can be associated with a name, but it's not mandatory.

func (*Client) ContainerDiff

func (cli *Client) ContainerDiff(containerID string) ([]types.ContainerChange, error)

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

func (*Client) ContainerExecAttach

func (cli *Client) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error)

ContainerExecAttach attaches a connection to an exec process in the server. It returns a types.HijackedConnection with the hijacked connection and the a reader to get output. It's up to the called to close the hijacked connection by calling types.HijackedResponse.Close.

func (*Client) ContainerExecCreate

func (cli *Client) ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error)

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

func (*Client) ContainerExecInspect

func (cli *Client) ContainerExecInspect(execID string) (types.ContainerExecInspect, error)

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

func (*Client) ContainerExecResize

func (cli *Client) ContainerExecResize(options types.ResizeOptions) error

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

func (*Client) ContainerExecStart

func (cli *Client) ContainerExecStart(execID string, config types.ExecStartCheck) error

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

func (*Client) ContainerExport

func (cli *Client) ContainerExport(containerID string) (io.ReadCloser, error)

ContainerExport retrieves the raw contents of a container and returns them as a io.ReadCloser. It's up to the caller to close the stream.

func (*Client) ContainerInspect

func (cli *Client) ContainerInspect(containerID string) (types.ContainerJSON, error)

ContainerInspect returns the container information.

func (*Client) ContainerInspectWithRaw

func (cli *Client) ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error)

ContainerInspectWithRaw returns the container information and it's raw representation.

func (*Client) ContainerKill

func (cli *Client) ContainerKill(containerID, signal string) error

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

func (*Client) ContainerList

func (cli *Client) ContainerList(options types.ContainerListOptions) ([]types.Container, error)

ContainerList returns the list of containers in the docker host.

func (*Client) ContainerLogs

func (cli *Client) ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error)

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

func (*Client) ContainerPause

func (cli *Client) ContainerPause(containerID string) error

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

func (*Client) ContainerRemove

func (cli *Client) ContainerRemove(options types.ContainerRemoveOptions) error

ContainerRemove kills and removes a container from the docker host.

func (*Client) ContainerRename

func (cli *Client) ContainerRename(containerID, newContainerName string) error

ContainerRename changes the name of a given container.

func (*Client) ContainerResize

func (cli *Client) ContainerResize(options types.ResizeOptions) error

ContainerResize changes the size of the tty for a container.

func (*Client) ContainerRestart

func (cli *Client) ContainerRestart(containerID string, timeout int) error

ContainerRestart stops and starts a container again. It makes the daemon to wait for the container to be up again for a specific amount of time, given the timeout.

func (*Client) ContainerStart

func (cli *Client) ContainerStart(containerID string) error

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

func (*Client) ContainerStatPath

func (cli *Client) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error)

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

func (*Client) ContainerStats

func (cli *Client) ContainerStats(containerID string, stream bool) (io.ReadCloser, error)

ContainerStats returns near realtime stats for a given container. It's up to the caller to close the io.ReadCloser returned.

func (*Client) ContainerStop

func (cli *Client) ContainerStop(containerID string, timeout int) error

ContainerStop stops a container without terminating the process. The process is blocked until the container stops or the timeout expires.

func (*Client) ContainerTop

func (cli *Client) ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error)

ContainerTop shows process information from within a container.

func (*Client) ContainerUnpause

func (cli *Client) ContainerUnpause(containerID string) error

ContainerUnpause resumes the process execution within a container

func (*Client) ContainerUpdate

func (cli *Client) ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error

ContainerUpdate updates resources of a container

func (*Client) ContainerWait

func (cli *Client) ContainerWait(containerID string) (int, error)

ContainerWait pauses execution util a container is exits. It returns the API status code as response of its readiness.

func (*Client) CopyFromContainer

func (cli *Client) CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)

CopyFromContainer get the content from the container and return it as a Reader to manipulate it in the host. It's up to the caller to close the reader.

func (*Client) CopyToContainer

func (cli *Client) CopyToContainer(options types.CopyToContainerOptions) error

CopyToContainer copies content into the container filesystem.

func (*Client) Events

func (cli *Client) Events(options types.EventsOptions) (io.ReadCloser, error)

Events returns a stream of events in the daemon in a ReadCloser. It's up to the caller to close the stream.

func (*Client) ImageBuild

func (cli *Client) ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error)

ImageBuild sends request to the daemon to build images. The Body in the response implement an io.ReadCloser and it's up to the caller to close it.

func (*Client) ImageCreate

func (cli *Client) ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error)

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

func (*Client) ImageHistory

func (cli *Client) ImageHistory(imageID string) ([]types.ImageHistory, error)

ImageHistory returns the changes in an image in history format.

func (*Client) ImageImport

func (cli *Client) ImageImport(options types.ImageImportOptions) (io.ReadCloser, error)

ImageImport creates a new image based in the source options. It returns the JSON content in the response body.

func (*Client) ImageInspectWithRaw

func (cli *Client) ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error)

ImageInspectWithRaw returns the image information and it's raw representation.

func (*Client) ImageList

func (cli *Client) ImageList(options types.ImageListOptions) ([]types.Image, error)

ImageList returns a list of images in the docker host.

func (*Client) ImageLoad

func (cli *Client) ImageLoad(input io.Reader) (types.ImageLoadResponse, error)

ImageLoad loads an image in the docker host from the client host. It's up to the caller to close the io.ReadCloser returned by this function.

func (*Client) ImagePull

func (cli *Client) ImagePull(options types.ImagePullOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error)

ImagePull request the docker host to pull an image from a remote registry. It executes the privileged function if the operation is unauthorized and it tries one more time. It's up to the caller to handle the io.ReadCloser and close it properly.

func (*Client) ImagePush

func (cli *Client) ImagePush(options types.ImagePushOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error)

ImagePush request the docker host to push an image to a remote registry. It executes the privileged function if the operation is unauthorized and it tries one more time. It's up to the caller to handle the io.ReadCloser and close it properly.

func (*Client) ImageRemove

func (cli *Client) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error)

ImageRemove removes an image from the docker host.

func (*Client) ImageSave

func (cli *Client) ImageSave(imageIDs []string) (io.ReadCloser, error)

ImageSave retrieves one or more images from the docker host as a io.ReadCloser. It's up to the caller to store the images and close the stream.

func (*Client) ImageSearch

func (cli *Client) ImageSearch(options types.ImageSearchOptions, privilegeFunc RequestPrivilegeFunc) ([]registry.SearchResult, error)

ImageSearch makes the docker host to 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(options types.ImageTagOptions) error

ImageTag tags an image in the docker host

func (*Client) Info

func (cli *Client) Info() (types.Info, error)

Info returns information about the docker server.

func (*Client) NetworkConnect

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

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

func (*Client) NetworkCreate

func (cli *Client) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error)

NetworkCreate creates a new network in the docker host.

func (*Client) NetworkDisconnect

func (cli *Client) NetworkDisconnect(networkID, containerID string, force bool) error

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

func (*Client) NetworkInspect

func (cli *Client) NetworkInspect(networkID string) (types.NetworkResource, error)

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

func (*Client) NetworkList

func (cli *Client) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error)

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

func (*Client) NetworkRemove

func (cli *Client) NetworkRemove(networkID string) error

NetworkRemove removes an existent network from the docker host.

func (*Client) RegistryLogin

func (cli *Client) RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error)

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

func (*Client) ServerVersion

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

ServerVersion returns information of the docker client and server host.

func (*Client) VolumeCreate

func (cli *Client) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error)

VolumeCreate creates a volume in the docker host.

func (*Client) VolumeInspect

func (cli *Client) VolumeInspect(volumeID string) (types.Volume, error)

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

func (*Client) VolumeList

func (cli *Client) VolumeList(filter filters.Args) (types.VolumesListResponse, error)

VolumeList returns the volumes configured in the docker host.

func (*Client) VolumeRemove

func (cli *Client) VolumeRemove(volumeID string) error

VolumeRemove removes a volume from the docker host.

type RequestPrivilegeFunc

type RequestPrivilegeFunc func() (string, error)

RequestPrivilegeFunc is a function interface that clients can supply to retry operations after getting an authorization error. This function returns the registry authentication header value in base 64 format, or an error if the privilege request fails.

Jump to

Keyboard shortcuts

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