docker

package
v0.0.0-...-dd9b67b Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2014 License: BSD-2-Clause, MIT Imports: 15 Imported by: 0

README

#go-dockerclient

Build Status

This package presents a client for the Docker remote API.

For more details, check the remote API documentation: http://docs.docker.io/en/latest/api/docker_remote_api.

Documentation

Overview

Package docker provides a client for the Docker remote API.

See http://goo.gl/mxyql for more details on the remote API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEndpoint is returned when the endpoint is not a valid HTTP URL.
	ErrInvalidEndpoint = errors.New("Invalid endpoint")

	// ErrConnectionRefused is returned when the client cannot connect to the given endpoint.
	ErrConnectionRefused = errors.New("Cannot connect to Docker endpoint")
)
View Source
var ErrNoSuchImage = errors.New("No such image")

Error returned when the image does not exist.

Functions

This section is empty.

Types

type APIContainers

type APIContainers struct {
	ID         string `json:"Id"`
	Image      string
	Command    string
	Created    int64
	Status     string
	Ports      []APIPort
	SizeRw     int64
	SizeRootFs int64
	Names      []string
}

type APIImages

type APIImages struct {
	ID          string   `json:"Id"`
	RepoTags    []string `json:",omitempty"`
	Created     int64
	Size        int64
	VirtualSize int64
	ParentId    string `json:",omitempty"`
}

type APIInfo

type APIInfo struct {
	Debug              bool
	Containers         int
	Images             int
	NFd                int    `json:",omitempty"`
	NGoroutines        int    `json:",omitempty"`
	MemoryLimit        bool   `json:",omitempty"`
	SwapLimit          bool   `json:",omitempty"`
	IPv4Forwarding     bool   `json:",omitempty"`
	LXCVersion         string `json:",omitempty"`
	NEventsListener    int    `json:",omitempty"`
	KernelVersion      string `json:",omitempty"`
	IndexServerAddress string `json:",omitempty"`
}

type APIPort

type APIPort struct {
	PrivatePort int64
	PublicPort  int64
	Type        string
	IP          string
}

type APIVersion

type APIVersion struct {
	Version   string
	GitCommit string `json:",omitempty"`
	GoVersion string `json:",omitempty"`
}

type AttachToContainerOptions

type AttachToContainerOptions struct {
	Container    string
	InputStream  io.Reader
	OutputStream io.Writer

	// Get container logs, sending it to OutputStream.
	Logs bool

	// Stream the response?
	Stream bool

	// Attach to stdin, and use InputFile.
	Stdin bool

	// Attach to stdout, and use OutputStream.
	Stdout bool

	// Attach to stderr, and use ErrorStream.
	Stderr bool

	// If set, after a successful connect, a sentinel will be sent and then the
	// client will block on receive before continuing.
	Success chan struct{}
}

AttachToContainerOptions is the set of options that can be used when attaching to a container.

See http://goo.gl/oPzcqH for more details.

type AuthConfiguration

type AuthConfiguration struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email,omitempty"`
}

AuthConfiguration represents authentication options to use in the PushImage method. It represents the authencation in the Docker index server.

type Client

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

Client is the basic type of this package. It provides methods for interaction with the API.

func NewClient

func NewClient(endpoint string) (*Client, error)

NewClient returns a Client instance ready for communication with the given server endpoint.

func (*Client) AttachToContainer

func (c *Client) AttachToContainer(opts AttachToContainerOptions) error

AttachToContainer attaches to a container, using the given options.

See http://goo.gl/oPzcqH for more details.

func (*Client) CommitContainer

func (c *Client) CommitContainer(opts CommitContainerOptions) (*Image, error)

CommitContainer creates a new image from a container's changes.

See http://goo.gl/628gxm for more details.

func (*Client) CreateContainer

func (c *Client) CreateContainer(config *Config) (*Container, error)

CreateContainer creates a new container, returning the container instance, or an error in case of failure.

See http://goo.gl/tjihUc for more details.

func (*Client) Events

func (c *Client) Events() (*EventStream, error)

Events returns a stream of container events.

func (*Client) ExportContainer

func (c *Client) ExportContainer(id string, out io.Writer) error

ExportContainer export the contents of container id as tar archive and prints the exported contents to stdout.

see http://goo.gl/Lqk0FZ for more details.

func (*Client) ImportImage

func (c *Client) ImportImage(opts ImportImageOptions, in io.Reader, out io.Writer) error

ImportImage imports an image from a url, a file or stdin

See http://goo.gl/PhBKnS for more details.

func (*Client) Info

func (c *Client) Info() (*APIInfo, error)

Info returns system-wide information, like the number of running containers.

See http://goo.gl/LOmySw for more details.

func (*Client) InspectContainer

func (c *Client) InspectContainer(id string) (*Container, error)

InspectContainer returns information about a container by its ID.

See http://goo.gl/2o52Sx for more details.

func (*Client) InspectImage

func (c *Client) InspectImage(name string) (*Image, error)

InspectImage returns an image by its name or ID.

See http://goo.gl/pHEbma for more details.

func (*Client) KillContainer

func (c *Client) KillContainer(id string) error

KillContainer kills a container, returning an error in case of failure.

See http://goo.gl/DPbbBy for more details.

func (*Client) ListContainers

func (c *Client) ListContainers(opts ListContainersOptions) ([]APIContainers, error)

ListContainers returns a slice of containers matching the given criteria.

See http://goo.gl/QpCnDN for more details.

func (*Client) ListImages

func (c *Client) ListImages(all bool) ([]APIImages, error)

ListImages returns the list of available images in the server.

See http://goo.gl/dkMrwP for more details.

func (*Client) PullImage

func (c *Client) PullImage(opts PullImageOptions, w io.Writer) error

PullImage pulls an image from a remote registry, logging progress to w.

See http://goo.gl/PhBKnS for more details.

func (*Client) PushImage

func (c *Client) PushImage(opts PushImageOptions, auth AuthConfiguration, w io.Writer) error

PushImage pushes an image to a remote registry, logging progress to w.

An empty instance of AuthConfiguration may be used for unauthenticated pushes.

See http://goo.gl/GBmyhc for more details.

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(id string) error

RemoveContainer removes a container, returning an error in case of failure.

See http://goo.gl/PBvGdU for more details.

func (*Client) RemoveImage

func (c *Client) RemoveImage(name string) error

RemoveImage removes an image by its name or ID.

See http://goo.gl/7hjHHy for more details.

func (*Client) ResizeContainerTTY

func (c *Client) ResizeContainerTTY(id string, height, width int) error

func (*Client) RestartContainer

func (c *Client) RestartContainer(id string, timeout uint) error

RestartContainer stops a container, killing it after the given timeout (in seconds), during the stop process.

See http://goo.gl/zms73Z for more details.

func (*Client) StartContainer

func (c *Client) StartContainer(id string, hostConfig *HostConfig) error

StartContainer starts a container, returning an errror in case of failure.

See http://goo.gl/y5GZlE for more details.

func (*Client) StopContainer

func (c *Client) StopContainer(id string, timeout uint) error

StopContainer stops a container, killing it after the given timeout (in seconds).

See http://goo.gl/X2mj8t for more details.

func (*Client) Version

func (c *Client) Version() (*APIVersion, error)

Version returns version information about the docker server.

See http://goo.gl/IqKNRE for more details.

func (*Client) WaitContainer

func (c *Client) WaitContainer(id string) (int, error)

WaitContainer blocks until the given container stops, return the exit code of the container status.

See http://goo.gl/gnHJL2 for more details.

type CommitContainerOptions

type CommitContainerOptions struct {
	Container  string
	Repository string `qs:"repo"`
	Tag        string
	Message    string `qs:"m"`
	Author     string
	Run        *Config
}

CommitContainerOptions aggregates parameters to the CommitContainer method.

See http://goo.gl/628gxm for more details.

type Config

type Config struct {
	Hostname        string
	Domainname      string
	User            string
	Memory          int64 // Memory limit (in bytes)
	MemorySwap      int64 // Total memory usage (memory + swap); set `-1' to disable swap
	CpuShares       int64 // CPU shares (relative weight vs. other containers)
	AttachStdin     bool
	AttachStdout    bool
	AttachStderr    bool
	PortSpecs       []string // Deprecated - Can be in the format of 8080/tcp
	ExposedPorts    map[string]struct{}
	Tty             bool // Attach standard streams to a tty, including stdin if it is not closed.
	OpenStdin       bool // Open stdin
	StdinOnce       bool // If true, close stdin after the 1 attached client disconnects.
	Env             []string
	Cmd             []string
	Dns             []string
	Image           string // Name of the image as it was passed by the operator (eg. could be symbolic)
	Volumes         map[string]struct{}
	VolumesFrom     string
	WorkingDir      string
	Entrypoint      []string
	NetworkDisabled bool
	Name            string `json:"-"`
}

type Container

type Container struct {
	ID string

	Created time.Time

	Path string
	Args []string

	Config *Config
	State  State
	Image  string

	NetworkSettings *NetworkSettings

	SysInitPath    string
	ResolvConfPath string
	HostnamePath   string
	HostsPath      string
	Name           string
	Driver         string

	Volumes   map[string]string
	VolumesRW map[string]bool
}

type Error

type Error struct {
	Status  int
	Message string
}

Error represents failures in the API. It represents a failure from the API.

func (*Error) Error

func (e *Error) Error() string

type Event

type Event struct {
	Status   string    `json:"status,omitempty"`
	Progress string    `json:"progress,omitempty"`
	ID       string    `json:"id,omitempty"`
	From     string    `json:"from,omitempty"`
	Time     int64     `json:"time,omitempty"`
	Error    *EventErr `json:"errorDetail,omitempty"`
}

type EventErr

type EventErr struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type EventStream

type EventStream struct {
	Events chan *Event
	// Error must only be read after Stream has closed
	Error error
	// contains filtered or unexported fields
}

func (*EventStream) Close

func (s *EventStream) Close() error

type HostConfig

type HostConfig struct {
	Binds           []string
	ContainerIDFile string
	LxcConf         []KeyValuePair
	Privileged      bool
	PortBindings    map[string][]PortBinding
	Links           []string
	PublishAllPorts bool
}

type Image

type Image struct {
	ID              string    `json:"id"`
	Parent          string    `json:"parent,omitempty"`
	Comment         string    `json:"comment,omitempty"`
	Created         time.Time `json:"created"`
	Container       string    `json:"container,omitempty"`
	ContainerConfig Config    `json:"container_config,omitempty"`
	DockerVersion   string    `json:"docker_version,omitempty"`
	Author          string    `json:"author,omitempty"`
	Config          *Config   `json:"config,omitempty"`
	Architecture    string    `json:"architecture,omitempty"`
	Size            int64
}

type ImportImageOptions

type ImportImageOptions struct {
	Repository string `qs:"repo"`
	Source     string `qs:"fromSrc"`
}

ImportImageOptions present the set of informations available for importing an image from a source file or the stdin.

See http://goo.gl/PhBKnS for more details.

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

type ListContainersOptions

type ListContainersOptions struct {
	All    bool
	Size   bool
	Limit  int
	Since  string
	Before string
}

ListContainersOptions specify parameters to the ListContainers function.

See http://goo.gl/QpCnDN for more details.

type NetworkSettings

type NetworkSettings struct {
	IPAddress   string
	IPPrefixLen int
	Gateway     string
	Bridge      string
	PortMapping map[string]PortMapping // Deprecated
	Ports       map[string][]PortBinding
}

type NoSuchContainer

type NoSuchContainer struct {
	ID string
}

NoSuchContainer is the error returned when a given container does not exist.

func (NoSuchContainer) Error

func (err NoSuchContainer) Error() string

type PortBinding

type PortBinding struct {
	HostIp   string
	HostPort string
}

type PortMapping

type PortMapping map[string]string

type PullImageOptions

type PullImageOptions struct {
	Repository string `qs:"fromImage"`
	Registry   string
}

PullImageOptions present the set of options available for pulling an image from a registry.

See http://goo.gl/PhBKnS for more details.

type PushImageOptions

type PushImageOptions struct {
	// Name of the image
	Name string

	// Registry server to push the image
	Registry string
}

PushImageOptions represents options to use in the PushImage method.

See http://goo.gl/GBmyhc for more details.

type State

type State struct {
	Running   bool
	Pid       int
	ExitCode  int
	StartedAt time.Time
	Ghost     bool
}

Jump to

Keyboard shortcuts

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