Documentation ¶
Overview ¶
Package docker provides a client for the Docker remote API.
See https://goo.gl/G3plxW for more details on the remote API.
Index ¶
- Constants
- Variables
- func DefaultDockerHost() (string, error)
- func ParseRepositoryTag(repoTag string) (repository string, tag string)
- type APIActor
- type APIContainers
- type APIEvents
- type APIImageSearch
- type APIImages
- type APIPort
- type APIVersion
- type AttachToContainerOptions
- type AuthConfiguration
- type AuthConfigurations
- type AuthConfigurations119
- type BlkioStatsEntry
- type BlockLimit
- type BlockWeight
- type BuildArg
- type BuildImageOptions
- type CPUStats
- type Change
- type ChangeType
- type Client
- func NewClient(endpoint string) (*Client, error)
- func NewClientFromEnv() (*Client, error)
- func NewTLSClient(endpoint string, cert, key, ca string) (*Client, error)
- func NewTLSClientFromBytes(endpoint string, certPEMBlock, keyPEMBlock, caPEMCert []byte) (*Client, error)
- func NewVersionedClient(endpoint string, apiVersionString string) (*Client, error)
- func NewVersionedClientFromEnv(apiVersionString string) (*Client, error)
- func NewVersionedTLSClient(endpoint string, cert, key, ca, apiVersionString string) (*Client, error)
- func NewVersionedTLSClientFromBytes(endpoint string, certPEMBlock, keyPEMBlock, caPEMCert []byte, ...) (*Client, error)
- func NewVersionnedTLSClient(endpoint string, cert, key, ca, apiVersionString string) (*Client, error)
- func (c *Client) AddEventListener(listener chan<- *APIEvents) error
- func (c *Client) AttachToContainer(opts AttachToContainerOptions) error
- func (c *Client) AttachToContainerNonBlocking(opts AttachToContainerOptions) (CloseWaiter, error)
- func (c *Client) AuthCheck(conf *AuthConfiguration) error
- func (c *Client) BuildImage(opts BuildImageOptions) error
- func (c *Client) CommitContainer(opts CommitContainerOptions) (*Image, error)
- func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error
- func (c *Client) ContainerChanges(id string) ([]Change, error)
- func (c *Client) CopyFromContainer(opts CopyFromContainerOptions) error
- func (c *Client) CreateContainer(opts CreateContainerOptions) (*Container, error)
- func (c *Client) CreateExec(opts CreateExecOptions) (*Exec, error)
- func (c *Client) CreateNetwork(opts CreateNetworkOptions) (*Network, error)
- func (c *Client) CreateVolume(opts CreateVolumeOptions) (*Volume, error)
- func (c *Client) DisconnectNetwork(id string, opts NetworkConnectionOptions) error
- func (c *Client) DownloadFromContainer(id string, opts DownloadFromContainerOptions) error
- func (c *Client) Endpoint() string
- func (c *Client) ExportContainer(opts ExportContainerOptions) error
- func (c *Client) ExportImage(opts ExportImageOptions) error
- func (c *Client) ExportImages(opts ExportImagesOptions) error
- func (c *Client) FilteredListNetworks(opts NetworkFilterOpts) ([]Network, error)
- func (c *Client) ImageHistory(name string) ([]ImageHistory, error)
- func (c *Client) ImportImage(opts ImportImageOptions) error
- func (c *Client) Info() (*DockerInfo, error)
- func (c *Client) InspectContainer(id string) (*Container, error)
- func (c *Client) InspectExec(id string) (*ExecInspect, error)
- func (c *Client) InspectImage(name string) (*Image, error)
- func (c *Client) InspectVolume(name string) (*Volume, error)
- func (c *Client) KillContainer(opts KillContainerOptions) error
- func (c *Client) ListContainers(opts ListContainersOptions) ([]APIContainers, error)
- func (c *Client) ListImages(opts ListImagesOptions) ([]APIImages, error)
- func (c *Client) ListNetworks() ([]Network, error)
- func (c *Client) ListVolumes(opts ListVolumesOptions) ([]Volume, error)
- func (c *Client) LoadImage(opts LoadImageOptions) error
- func (c *Client) Logs(opts LogsOptions) error
- func (c *Client) NetworkInfo(id string) (*Network, error)
- func (c *Client) PauseContainer(id string) error
- func (c *Client) Ping() error
- func (c *Client) PullImage(opts PullImageOptions, auth AuthConfiguration) error
- func (c *Client) PushImage(opts PushImageOptions, auth AuthConfiguration) error
- func (c *Client) RemoveContainer(opts RemoveContainerOptions) error
- func (c *Client) RemoveEventListener(listener chan *APIEvents) error
- func (c *Client) RemoveImage(name string) error
- func (c *Client) RemoveImageExtended(name string, opts RemoveImageOptions) error
- func (c *Client) RemoveNetwork(id string) error
- func (c *Client) RemoveVolume(name string) error
- func (c *Client) RenameContainer(opts RenameContainerOptions) error
- func (c *Client) ResizeContainerTTY(id string, height, width int) error
- func (c *Client) ResizeExecTTY(id string, height, width int) error
- func (c *Client) RestartContainer(id string, timeout uint) error
- func (c *Client) SearchImages(term string) ([]APIImageSearch, error)
- func (c *Client) SearchImagesEx(term string, auth AuthConfiguration) ([]APIImageSearch, error)
- func (c *Client) StartContainer(id string, hostConfig *HostConfig) error
- func (c *Client) StartExec(id string, opts StartExecOptions) error
- func (c *Client) StartExecNonBlocking(id string, opts StartExecOptions) (CloseWaiter, error)
- func (c *Client) Stats(opts StatsOptions) (retErr error)
- func (c *Client) StopContainer(id string, timeout uint) error
- func (c *Client) TagImage(name string, opts TagImageOptions) error
- func (c *Client) TopContainer(id string, psArgs string) (TopResult, error)
- func (c *Client) UnpauseContainer(id string) error
- func (c *Client) UpdateContainer(id string, opts UpdateContainerOptions) error
- func (c *Client) UploadToContainer(id string, opts UploadToContainerOptions) error
- func (c *Client) Version() (*Env, error)
- func (c *Client) WaitContainer(id string) (int, error)
- type CloseWaiter
- type CommitContainerOptions
- type Config
- type Container
- type ContainerAlreadyRunning
- type ContainerNetwork
- type ContainerNotRunning
- type CopyFromContainerOptions
- type CreateContainerOptions
- type CreateExecOptions
- type CreateNetworkOptions
- type CreateVolumeOptions
- type Device
- type DockerInfo
- type DownloadFromContainerOptions
- type Endpoint
- type EndpointConfig
- type EndpointIPAMConfig
- type Env
- func (env *Env) Decode(src io.Reader) error
- func (env *Env) Exists(key string) bool
- func (env *Env) Get(key string) (value string)
- func (env *Env) GetBool(key string) (value bool)
- func (env *Env) GetInt(key string) int
- func (env *Env) GetInt64(key string) int64
- func (env *Env) GetJSON(key string, iface interface{}) error
- func (env *Env) GetList(key string) []string
- func (env *Env) Map() map[string]string
- func (env *Env) Set(key, value string)
- func (env *Env) SetAuto(key string, value interface{})
- func (env *Env) SetBool(key string, value bool)
- func (env *Env) SetInt(key string, value int)
- func (env *Env) SetInt64(key string, value int64)
- func (env *Env) SetJSON(key string, value interface{}) error
- func (env *Env) SetList(key string, value []string) error
- type Error
- type Exec
- type ExecInspect
- type ExecProcessConfig
- type ExportContainerOptions
- type ExportImageOptions
- type ExportImagesOptions
- type HostConfig
- type IPAMConfig
- type IPAMOptions
- type Image
- type ImageHistory
- type ImagePre012
- type ImportImageOptions
- type KeyValuePair
- type KillContainerOptions
- type ListContainersOptions
- type ListImagesOptions
- type ListVolumesOptions
- type LoadImageOptions
- type LogConfig
- type LogsOptions
- type Mount
- type Network
- type NetworkConnectionOptions
- type NetworkFilterOpts
- type NetworkList
- type NetworkSettings
- type NetworkStats
- type NoSuchContainer
- type NoSuchExec
- type NoSuchNetwork
- type NoSuchNetworkOrContainer
- type PluginsInfo
- type Port
- type PortBinding
- type PortMapping
- type PullImageOptions
- type PushImageOptions
- type RemoveContainerOptions
- type RemoveImageOptions
- type RenameContainerOptions
- type RestartPolicy
- type Signal
- type StartExecOptions
- type State
- type Stats
- type StatsOptions
- type SwarmNode
- type TagImageOptions
- type TopResult
- type ULimit
- type UpdateContainerOptions
- type UploadToContainerOptions
- type Volume
Examples ¶
Constants ¶
const ( SIGABRT = Signal(0x6) SIGALRM = Signal(0xe) SIGBUS = Signal(0x7) SIGCHLD = Signal(0x11) SIGCLD = Signal(0x11) SIGCONT = Signal(0x12) SIGFPE = Signal(0x8) SIGHUP = Signal(0x1) SIGILL = Signal(0x4) SIGINT = Signal(0x2) SIGIO = Signal(0x1d) SIGIOT = Signal(0x6) SIGKILL = Signal(0x9) SIGPIPE = Signal(0xd) SIGPOLL = Signal(0x1d) SIGPROF = Signal(0x1b) SIGPWR = Signal(0x1e) SIGQUIT = Signal(0x3) SIGSEGV = Signal(0xb) SIGSTKFLT = Signal(0x10) SIGSTOP = Signal(0x13) SIGSYS = Signal(0x1f) SIGTERM = Signal(0xf) SIGTRAP = Signal(0x5) SIGTSTP = Signal(0x14) SIGTTIN = Signal(0x15) SIGTTOU = Signal(0x16) SIGUNUSED = Signal(0x1f) SIGURG = Signal(0x17) SIGUSR1 = Signal(0xa) SIGUSR2 = Signal(0xc) SIGVTALRM = Signal(0x1a) SIGWINCH = Signal(0x1c) SIGXCPU = Signal(0x18) SIGXFSZ = Signal(0x19) )
These values represent all signals available on Linux, where containers will be running.
Variables ¶
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") )
var ( // ErrNoListeners is the error returned when no listeners are available // to receive an event. ErrNoListeners = errors.New("no listeners present to receive event") // ErrListenerAlreadyExists is the error returned when the listerner already // exists. ErrListenerAlreadyExists = errors.New("listener already exists for docker events") // EOFEvent is sent when the event listener receives an EOF error. EOFEvent = &APIEvents{ Type: "EOF", Status: "EOF", } )
var ( // ErrNoSuchImage is the error returned when the image does not exist. ErrNoSuchImage = errors.New("no such image") // ErrMissingRepo is the error returned when the remote repository is // missing. ErrMissingRepo = errors.New("missing remote repository e.g. 'github.com/user/repo'") // ErrMissingOutputStream is the error returned when no output stream // is provided to some calls, like BuildImage. ErrMissingOutputStream = errors.New("missing output stream") // ErrMultipleContexts is the error returned when both a ContextDir and // InputStream are provided in BuildImageOptions ErrMultipleContexts = errors.New("image build may not be provided BOTH context dir and input stream") // ErrMustSpecifyNames is the error rreturned when the Names field on // ExportImagesOptions is nil or empty ErrMustSpecifyNames = errors.New("must specify at least one name to export") )
var ( // ErrNoSuchVolume is the error returned when the volume does not exist. ErrNoSuchVolume = errors.New("no such volume") // ErrVolumeInUse is the error returned when the volume requested to be removed is still in use. ErrVolumeInUse = errors.New("volume in use and cannot be removed") )
var ErrCannotParseDockercfg = errors.New("Failed to read authentication from dockercfg")
ErrCannotParseDockercfg is the error returned by NewAuthConfigurations when the dockercfg cannot be parsed.
var ErrContainerAlreadyExists = errors.New("container already exists")
ErrContainerAlreadyExists is the error returned by CreateContainer when the container already exists.
var ErrNetworkAlreadyExists = errors.New("network already exists")
ErrNetworkAlreadyExists is the error returned by CreateNetwork when the network already exists.
Functions ¶
func DefaultDockerHost ¶
DefaultDockerHost returns the default docker socket for the current OS
func ParseRepositoryTag ¶
ParseRepositoryTag gets the name of the repository and returns it splitted in two parts: the repository and the tag.
Some examples:
localhost.localdomain:5000/samalba/hipache:latest -> localhost.localdomain:5000/samalba/hipache, latest localhost.localdomain:5000/samalba/hipache -> localhost.localdomain:5000/samalba/hipache, ""
Types ¶
type APIActor ¶
type APIActor struct { ID string `json:"id,omitempty"` Attributes map[string]string `json:"attributes,omitempty"` }
APIActor represents an actor that accomplishes something for an event
type APIContainers ¶
type APIContainers struct { ID string `json:"Id" yaml:"Id"` Image string `json:"Image,omitempty" yaml:"Image,omitempty"` Command string `json:"Command,omitempty" yaml:"Command,omitempty"` Created int64 `json:"Created,omitempty" yaml:"Created,omitempty"` Status string `json:"Status,omitempty" yaml:"Status,omitempty"` Ports []APIPort `json:"Ports,omitempty" yaml:"Ports,omitempty"` SizeRw int64 `json:"SizeRw,omitempty" yaml:"SizeRw,omitempty"` SizeRootFs int64 `json:"SizeRootFs,omitempty" yaml:"SizeRootFs,omitempty"` Names []string `json:"Names,omitempty" yaml:"Names,omitempty"` Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty"` Networks NetworkList `json:"NetworkSettings,omitempty" yaml:"NetworkSettings,omitempty"` }
APIContainers represents each container in the list returned by ListContainers.
type APIEvents ¶
type APIEvents struct { // New API Fields in 1.22 Action string `json:"action,omitempty"` Type string `json:"type,omitempty"` Actor APIActor `json:"actor,omitempty"` // Old API fields for < 1.22 Status string `json:"status,omitempty"` ID string `json:"id,omitempty"` From string `json:"from,omitempty"` // Fields in both Time int64 `json:"time,omitempty"` TimeNano int64 `json:"timeNano,omitempty"` }
APIEvents represents events coming from the Docker API The fields in the Docker API changed in API version 1.22, and events for more than images and containers are now fired off. To maintain forward and backward compatibility, go-dockerclient replicates the event in both the new and old format as faithfully as possible.
For events that only exist in 1.22 in later, `Status` is filled in as `"Type:Action"` instead of just `Action` to allow for older clients to differentiate and not break if they rely on the pre-1.22 Status types.
The transformEvent method can be consulted for more information about how events are translated from new/old API formats
type APIImageSearch ¶
type APIImageSearch struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` IsOfficial bool `json:"is_official,omitempty" yaml:"is_official,omitempty"` IsAutomated bool `json:"is_automated,omitempty" yaml:"is_automated,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` StarCount int `json:"star_count,omitempty" yaml:"star_count,omitempty"` }
APIImageSearch reflect the result of a search on the Docker Hub.
See https://goo.gl/AYjyrF for more details.
type APIImages ¶
type APIImages struct { ID string `json:"Id" yaml:"Id"` RepoTags []string `json:"RepoTags,omitempty" yaml:"RepoTags,omitempty"` Created int64 `json:"Created,omitempty" yaml:"Created,omitempty"` Size int64 `json:"Size,omitempty" yaml:"Size,omitempty"` VirtualSize int64 `json:"VirtualSize,omitempty" yaml:"VirtualSize,omitempty"` ParentID string `json:"ParentId,omitempty" yaml:"ParentId,omitempty"` RepoDigests []string `json:"RepoDigests,omitempty" yaml:"RepoDigests,omitempty"` Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty"` }
APIImages represent an image returned in the ListImages call.
type APIPort ¶
type APIPort struct { PrivatePort int64 `json:"PrivatePort,omitempty" yaml:"PrivatePort,omitempty"` PublicPort int64 `json:"PublicPort,omitempty" yaml:"PublicPort,omitempty"` Type string `json:"Type,omitempty" yaml:"Type,omitempty"` IP string `json:"IP,omitempty" yaml:"IP,omitempty"` }
APIPort is a type that represents a port mapping returned by the Docker API
type APIVersion ¶
type APIVersion []int
APIVersion is an internal representation of a version of the Remote API.
func NewAPIVersion ¶
func NewAPIVersion(input string) (APIVersion, error)
NewAPIVersion returns an instance of APIVersion for the given string.
The given string must be in the form <major>.<minor>.<patch>, where <major>, <minor> and <patch> are integer numbers.
func (APIVersion) GreaterThan ¶
func (version APIVersion) GreaterThan(other APIVersion) bool
GreaterThan is a function for comparing APIVersion structs
func (APIVersion) GreaterThanOrEqualTo ¶
func (version APIVersion) GreaterThanOrEqualTo(other APIVersion) bool
GreaterThanOrEqualTo is a function for comparing APIVersion structs
func (APIVersion) LessThan ¶
func (version APIVersion) LessThan(other APIVersion) bool
LessThan is a function for comparing APIVersion structs
func (APIVersion) LessThanOrEqualTo ¶
func (version APIVersion) LessThanOrEqualTo(other APIVersion) bool
LessThanOrEqualTo is a function for comparing APIVersion structs
func (APIVersion) String ¶
func (version APIVersion) String() string
type AttachToContainerOptions ¶
type AttachToContainerOptions struct { Container string `qs:"-"` InputStream io.Reader `qs:"-"` OutputStream io.Writer `qs:"-"` ErrorStream io.Writer `qs:"-"` // Get container logs, sending it to OutputStream. Logs bool // Stream the response? Stream bool // Attach to stdin, and use InputStream. 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. // // It must be an unbuffered channel. Using a buffered channel can lead // to unexpected behavior. Success chan struct{} // Use raw terminal? Usually true when the container contains a TTY. RawTerminal bool `qs:"-"` }
AttachToContainerOptions is the set of options that can be used when attaching to a container.
See https://goo.gl/NKpkFk for more details.
type AuthConfiguration ¶
type AuthConfiguration struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Email string `json:"email,omitempty"` ServerAddress string `json:"serveraddress,omitempty"` }
AuthConfiguration represents authentication options to use in the PushImage method. It represents the authentication in the Docker index server.
type AuthConfigurations ¶
type AuthConfigurations struct {
Configs map[string]AuthConfiguration `json:"configs"`
}
AuthConfigurations represents authentication options to use for the PushImage method accommodating the new X-Registry-Config header
func NewAuthConfigurations ¶
func NewAuthConfigurations(r io.Reader) (*AuthConfigurations, error)
NewAuthConfigurations returns AuthConfigurations from a JSON encoded string in the same format as the .dockercfg file.
func NewAuthConfigurationsFromDockerCfg ¶
func NewAuthConfigurationsFromDockerCfg() (*AuthConfigurations, error)
NewAuthConfigurationsFromDockerCfg returns AuthConfigurations from the ~/.dockercfg file.
type AuthConfigurations119 ¶
type AuthConfigurations119 map[string]AuthConfiguration
AuthConfigurations119 is used to serialize a set of AuthConfigurations for Docker API >= 1.19.
type BlkioStatsEntry ¶
type BlkioStatsEntry struct { Major uint64 `json:"major,omitempty" yaml:"major,omitempty"` Minor uint64 `json:"minor,omitempty" yaml:"minor,omitempty"` Op string `json:"op,omitempty" yaml:"op,omitempty"` Value uint64 `json:"value,omitempty" yaml:"value,omitempty"` }
BlkioStatsEntry is a stats entry for blkio_stats
type BlockLimit ¶
BlockLimit represents a read/write limit in IOPS or Bandwidth for a device inside of a container
See https://goo.gl/FSdP0H for more details.
type BlockWeight ¶
type BlockWeight struct { Path string `json:"Path,omitempty"` Weight string `json:"Weight,omitempty"` }
BlockWeight represents a relative device weight for an individual device inside of a container
See https://goo.gl/FSdP0H for more details.
type BuildArg ¶
type BuildArg struct { Name string `json:"Name,omitempty" yaml:"Name,omitempty"` Value string `json:"Value,omitempty" yaml:"Value,omitempty"` }
BuildArg represents arguments that can be passed to the image when building it from a Dockerfile.
For more details about the Docker building process, see http://goo.gl/tlPXPu.
type BuildImageOptions ¶
type BuildImageOptions struct { Name string `qs:"t"` Dockerfile string `qs:"dockerfile"` NoCache bool `qs:"nocache"` SuppressOutput bool `qs:"q"` Pull bool `qs:"pull"` RmTmpContainer bool `qs:"rm"` ForceRmTmpContainer bool `qs:"forcerm"` Memory int64 `qs:"memory"` Memswap int64 `qs:"memswap"` CPUQuota int64 `qs:"cpuquota"` CPUPeriod int64 `qs:"cpuperiod"` CPUSetCPUs string `qs:"cpusetcpus"` InputStream io.Reader `qs:"-"` OutputStream io.Writer `qs:"-"` RawJSONStream bool `qs:"-"` Remote string `qs:"remote"` Auth AuthConfiguration `qs:"-"` // for older docker X-Registry-Auth header AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Registry-Config header ContextDir string `qs:"-"` Ulimits []ULimit `qs:"-"` BuildArgs []BuildArg `qs:"-"` }
BuildImageOptions present the set of informations available for building an image from a tarfile with a Dockerfile in it.
For more details about the Docker building process, see http://goo.gl/tlPXPu.
type CPUStats ¶
type CPUStats struct { CPUUsage struct { PercpuUsage []uint64 `json:"percpu_usage,omitempty" yaml:"percpu_usage,omitempty"` UsageInUsermode uint64 `json:"usage_in_usermode,omitempty" yaml:"usage_in_usermode,omitempty"` TotalUsage uint64 `json:"total_usage,omitempty" yaml:"total_usage,omitempty"` UsageInKernelmode uint64 `json:"usage_in_kernelmode,omitempty" yaml:"usage_in_kernelmode,omitempty"` } `json:"cpu_usage,omitempty" yaml:"cpu_usage,omitempty"` SystemCPUUsage uint64 `json:"system_cpu_usage,omitempty" yaml:"system_cpu_usage,omitempty"` ThrottlingData struct { Periods uint64 `json:"periods,omitempty"` ThrottledPeriods uint64 `json:"throttled_periods,omitempty"` ThrottledTime uint64 `json:"throttled_time,omitempty"` } `json:"throttling_data,omitempty" yaml:"throttling_data,omitempty"` }
CPUStats is a stats entry for cpu stats
type Change ¶
type Change struct { Path string Kind ChangeType }
Change represents a change in a container.
See https://goo.gl/9GsTIF for more details.
type ChangeType ¶
type ChangeType int
ChangeType is a type for constants indicating the type of change in a container
const ( // ChangeModify is the ChangeType for container modifications ChangeModify ChangeType = iota // ChangeAdd is the ChangeType for additions to a container ChangeAdd // ChangeDelete is the ChangeType for deletions from a container ChangeDelete )
type Client ¶
type Client struct { SkipServerVersionCheck bool HTTPClient *http.Client TLSConfig *tls.Config Dialer *net.Dialer // contains filtered or unexported fields }
Client is the basic type of this package. It provides methods for interaction with the API.
func NewClient ¶
NewClient returns a Client instance ready for communication with the given server endpoint. It will use the latest remote API version available in the server.
func NewClientFromEnv ¶
NewClientFromEnv returns a Client instance ready for communication created from Docker's default logic for the environment variables DOCKER_HOST, DOCKER_TLS_VERIFY, and DOCKER_CERT_PATH.
See https://github.com/docker/docker/blob/1f963af697e8df3a78217f6fdbf67b8123a7db94/docker/docker.go#L68. See https://github.com/docker/compose/blob/81707ef1ad94403789166d2fe042c8a718a4c748/compose/cli/docker_client.py#L7.
func NewTLSClient ¶
NewTLSClient returns a Client instance ready for TLS communications with the givens server endpoint, key and certificates . It will use the latest remote API version available in the server.
func NewTLSClientFromBytes ¶
func NewTLSClientFromBytes(endpoint string, certPEMBlock, keyPEMBlock, caPEMCert []byte) (*Client, error)
NewTLSClientFromBytes returns a Client instance ready for TLS communications with the givens server endpoint, key and certificates (passed inline to the function as opposed to being read from a local file). It will use the latest remote API version available in the server.
func NewVersionedClient ¶
NewVersionedClient returns a Client instance ready for communication with the given server endpoint, using a specific remote API version.
func NewVersionedClientFromEnv ¶
NewVersionedClientFromEnv returns a Client instance ready for TLS communications created from Docker's default logic for the environment variables DOCKER_HOST, DOCKER_TLS_VERIFY, and DOCKER_CERT_PATH, and using a specific remote API version.
See https://github.com/docker/docker/blob/1f963af697e8df3a78217f6fdbf67b8123a7db94/docker/docker.go#L68. See https://github.com/docker/compose/blob/81707ef1ad94403789166d2fe042c8a718a4c748/compose/cli/docker_client.py#L7.
func NewVersionedTLSClient ¶
func NewVersionedTLSClient(endpoint string, cert, key, ca, apiVersionString string) (*Client, error)
NewVersionedTLSClient returns a Client instance ready for TLS communications with the givens server endpoint, key and certificates, using a specific remote API version.
func NewVersionedTLSClientFromBytes ¶
func NewVersionedTLSClientFromBytes(endpoint string, certPEMBlock, keyPEMBlock, caPEMCert []byte, apiVersionString string) (*Client, error)
NewVersionedTLSClientFromBytes returns a Client instance ready for TLS communications with the givens server endpoint, key and certificates (passed inline to the function as opposed to being read from a local file), using a specific remote API version.
func NewVersionnedTLSClient ¶
func NewVersionnedTLSClient(endpoint string, cert, key, ca, apiVersionString string) (*Client, error)
NewVersionnedTLSClient has been DEPRECATED, please use NewVersionedTLSClient.
func (*Client) AddEventListener ¶
AddEventListener adds a new listener to container events in the Docker API.
The parameter is a channel through which events will be sent.
func (*Client) AttachToContainer ¶
func (c *Client) AttachToContainer(opts AttachToContainerOptions) error
AttachToContainer attaches to a container, using the given options.
See https://goo.gl/NKpkFk for more details.
Example ¶
client, err := docker.NewClient("http://localhost:4243") if err != nil { log.Fatal(err) } client.SkipServerVersionCheck = true // Reading logs from container a84849 and sending them to buf. var buf bytes.Buffer err = client.AttachToContainer(docker.AttachToContainerOptions{ Container: "a84849", OutputStream: &buf, Logs: true, Stdout: true, Stderr: true, }) if err != nil { log.Fatal(err) } log.Println(buf.String()) buf.Reset() err = client.AttachToContainer(docker.AttachToContainerOptions{ Container: "a84849", OutputStream: &buf, Stdout: true, Stream: true, }) if err != nil { log.Fatal(err) } log.Println(buf.String())
Output:
func (*Client) AttachToContainerNonBlocking ¶
func (c *Client) AttachToContainerNonBlocking(opts AttachToContainerOptions) (CloseWaiter, error)
AttachToContainerNonBlocking attaches to a container, using the given options. This function does not block.
See https://goo.gl/NKpkFk for more details.
func (*Client) AuthCheck ¶
func (c *Client) AuthCheck(conf *AuthConfiguration) error
AuthCheck validates the given credentials. It returns nil if successful.
See https://goo.gl/m2SleN for more details.
func (*Client) BuildImage ¶
func (c *Client) BuildImage(opts BuildImageOptions) error
BuildImage builds an image from a tarball's url or a Dockerfile in the input stream.
See https://goo.gl/xySxCe for more details.
Example ¶
client, err := docker.NewClient("http://localhost:4243") if err != nil { log.Fatal(err) } t := time.Now() inputbuf, outputbuf := bytes.NewBuffer(nil), bytes.NewBuffer(nil) tr := tar.NewWriter(inputbuf) tr.WriteHeader(&tar.Header{Name: "Dockerfile", Size: 10, ModTime: t, AccessTime: t, ChangeTime: t}) tr.Write([]byte("FROM base\n")) tr.Close() opts := docker.BuildImageOptions{ Name: "test", InputStream: inputbuf, OutputStream: outputbuf, } if err := client.BuildImage(opts); err != nil { log.Fatal(err) }
Output:
func (*Client) CommitContainer ¶
func (c *Client) CommitContainer(opts CommitContainerOptions) (*Image, error)
CommitContainer creates a new image from a container's changes.
See https://goo.gl/mqfoCw for more details.
func (*Client) ConnectNetwork ¶
func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error
ConnectNetwork adds a container to a network or returns an error in case of failure.
See https://goo.gl/6GugX3 for more details.
func (*Client) ContainerChanges ¶
ContainerChanges returns changes in the filesystem of the given container.
See https://goo.gl/9GsTIF for more details.
func (*Client) CopyFromContainer ¶
func (c *Client) CopyFromContainer(opts CopyFromContainerOptions) error
CopyFromContainer has been DEPRECATED, please use DownloadFromContainerOptions along with DownloadFromContainer.
See https://goo.gl/R2jevW for more details.
Example ¶
client, err := docker.NewClient("http://localhost:4243") if err != nil { log.Fatal(err) } cid := "a84849" var buf bytes.Buffer filename := "/tmp/output.txt" err = client.CopyFromContainer(docker.CopyFromContainerOptions{ Container: cid, Resource: filename, OutputStream: &buf, }) if err != nil { log.Fatalf("Error while copying from %s: %s\n", cid, err) } content := new(bytes.Buffer) r := bytes.NewReader(buf.Bytes()) tr := tar.NewReader(r) tr.Next() if err != nil && err != io.EOF { log.Fatal(err) } if _, err := io.Copy(content, tr); err != nil { log.Fatal(err) } log.Println(buf.String())
Output:
func (*Client) CreateContainer ¶
func (c *Client) CreateContainer(opts CreateContainerOptions) (*Container, error)
CreateContainer creates a new container, returning the container instance, or an error in case of failure.
See https://goo.gl/WxQzrr for more details.
func (*Client) CreateExec ¶
func (c *Client) CreateExec(opts CreateExecOptions) (*Exec, error)
CreateExec sets up an exec instance in a running container `id`, returning the exec instance, or an error in case of failure.
See https://goo.gl/1KSIb7 for more details
func (*Client) CreateNetwork ¶
func (c *Client) CreateNetwork(opts CreateNetworkOptions) (*Network, error)
CreateNetwork creates a new network, returning the network instance, or an error in case of failure.
See https://goo.gl/6GugX3 for more details.
func (*Client) CreateVolume ¶
func (c *Client) CreateVolume(opts CreateVolumeOptions) (*Volume, error)
CreateVolume creates a volume on the server.
See https://goo.gl/pBUbZ9 for more details.
func (*Client) DisconnectNetwork ¶
func (c *Client) DisconnectNetwork(id string, opts NetworkConnectionOptions) error
DisconnectNetwork removes a container from a network or returns an error in case of failure.
See https://goo.gl/6GugX3 for more details.
func (*Client) DownloadFromContainer ¶
func (c *Client) DownloadFromContainer(id string, opts DownloadFromContainerOptions) error
DownloadFromContainer downloads a tar archive of files or folders in a container.
See https://goo.gl/KnZJDX for more details.
func (*Client) Endpoint ¶
Endpoint returns the current endpoint. It's useful for getting the endpoint when using functions that get this data from the environment (like NewClientFromEnv.
func (*Client) ExportContainer ¶
func (c *Client) ExportContainer(opts ExportContainerOptions) error
ExportContainer export the contents of container id as tar archive and prints the exported contents to stdout.
See https://goo.gl/dOkTyk for more details.
func (*Client) ExportImage ¶
func (c *Client) ExportImage(opts ExportImageOptions) error
ExportImage exports an image (as a tar file) into the stream.
See https://goo.gl/le7vK8 for more details.
func (*Client) ExportImages ¶
func (c *Client) ExportImages(opts ExportImagesOptions) error
ExportImages exports one or more images (as a tar file) into the stream
See https://goo.gl/huC7HA for more details.
func (*Client) FilteredListNetworks ¶
func (c *Client) FilteredListNetworks(opts NetworkFilterOpts) ([]Network, error)
FilteredListNetworks returns all networks with the filters applied
See goo.gl/zd2mx4 for more details.
func (*Client) ImageHistory ¶
func (c *Client) ImageHistory(name string) ([]ImageHistory, error)
ImageHistory returns the history of the image by its name or ID.
See https://goo.gl/8bnTId for more details.
func (*Client) ImportImage ¶
func (c *Client) ImportImage(opts ImportImageOptions) error
ImportImage imports an image from a url, a file or stdin
See https://goo.gl/iJkZjD for more details.
func (*Client) Info ¶
func (c *Client) Info() (*DockerInfo, error)
Info returns system-wide information about the Docker server.
See https://goo.gl/ElTHi2 for more details.
func (*Client) InspectContainer ¶
InspectContainer returns information about a container by its ID.
See https://goo.gl/RdIq0b for more details.
func (*Client) InspectExec ¶
func (c *Client) InspectExec(id string) (*ExecInspect, error)
InspectExec returns low-level information about the exec command id.
See https://goo.gl/gPtX9R for more details
func (*Client) InspectImage ¶
InspectImage returns an image by its name or ID.
See https://goo.gl/jHPcg6 for more details.
func (*Client) InspectVolume ¶
InspectVolume returns a volume by its name.
See https://goo.gl/0g9A6i for more details.
func (*Client) KillContainer ¶
func (c *Client) KillContainer(opts KillContainerOptions) error
KillContainer sends a signal to a container, returning an error in case of failure.
See https://goo.gl/hkS9i8 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 https://goo.gl/47a6tO for more details.
func (*Client) ListImages ¶
func (c *Client) ListImages(opts ListImagesOptions) ([]APIImages, error)
ListImages returns the list of available images in the server.
See https://goo.gl/xBe1u3 for more details.
func (*Client) ListNetworks ¶
ListNetworks returns all networks.
See https://goo.gl/6GugX3 for more details.
func (*Client) ListVolumes ¶
func (c *Client) ListVolumes(opts ListVolumesOptions) ([]Volume, error)
ListVolumes returns a list of available volumes in the server.
See https://goo.gl/FZA4BK for more details.
func (*Client) LoadImage ¶
func (c *Client) LoadImage(opts LoadImageOptions) error
LoadImage imports a tarball docker image
See https://goo.gl/JyClMX for more details.
func (*Client) Logs ¶
func (c *Client) Logs(opts LogsOptions) error
Logs gets stdout and stderr logs from the specified container.
See https://goo.gl/yl8PGm for more details.
func (*Client) NetworkInfo ¶
NetworkInfo returns information about a network by its ID.
See https://goo.gl/6GugX3 for more details.
func (*Client) PauseContainer ¶
PauseContainer pauses the given container.
See https://goo.gl/OF7W9X for more details.
func (*Client) PullImage ¶
func (c *Client) PullImage(opts PullImageOptions, auth AuthConfiguration) error
PullImage pulls an image from a remote registry, logging progress to opts.OutputStream.
See https://goo.gl/iJkZjD for more details.
func (*Client) PushImage ¶
func (c *Client) PushImage(opts PushImageOptions, auth AuthConfiguration) 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 https://goo.gl/zPtZaT for more details.
func (*Client) RemoveContainer ¶
func (c *Client) RemoveContainer(opts RemoveContainerOptions) error
RemoveContainer removes a container, returning an error in case of failure.
See https://goo.gl/RQyX62 for more details.
func (*Client) RemoveEventListener ¶
RemoveEventListener removes a listener from the monitor.
func (*Client) RemoveImage ¶
RemoveImage removes an image by its name or ID.
See https://goo.gl/V3ZWnK for more details.
func (*Client) RemoveImageExtended ¶
func (c *Client) RemoveImageExtended(name string, opts RemoveImageOptions) error
RemoveImageExtended removes an image by its name or ID. Extra params can be passed, see RemoveImageOptions
See https://goo.gl/V3ZWnK for more details.
func (*Client) RemoveNetwork ¶
RemoveNetwork removes a network or returns an error in case of failure.
See https://goo.gl/6GugX3 for more details.
func (*Client) RemoveVolume ¶
RemoveVolume removes a volume by its name.
See https://goo.gl/79GNQz for more details.
func (*Client) RenameContainer ¶
func (c *Client) RenameContainer(opts RenameContainerOptions) error
RenameContainer updates and existing containers name
See https://goo.gl/laSOIy for more details.
func (*Client) ResizeContainerTTY ¶
ResizeContainerTTY resizes the terminal to the given height and width.
See https://goo.gl/xERhCc for more details.
func (*Client) ResizeExecTTY ¶
ResizeExecTTY resizes the tty session used by the exec command id. This API is valid only if Tty was specified as part of creating and starting the exec command.
See https://goo.gl/e1JpsA for more details
func (*Client) RestartContainer ¶
RestartContainer stops a container, killing it after the given timeout (in seconds), during the stop process.
See https://goo.gl/QzsDnz for more details.
func (*Client) SearchImages ¶
func (c *Client) SearchImages(term string) ([]APIImageSearch, error)
SearchImages search the docker hub with a specific given term.
See https://goo.gl/AYjyrF for more details.
func (*Client) SearchImagesEx ¶
func (c *Client) SearchImagesEx(term string, auth AuthConfiguration) ([]APIImageSearch, error)
SearchImagesEx search the docker hub with a specific given term and authentication.
See https://goo.gl/AYjyrF for more details.
func (*Client) StartContainer ¶
func (c *Client) StartContainer(id string, hostConfig *HostConfig) error
StartContainer starts a container, returning an error in case of failure.
See https://goo.gl/MrBAJv for more details.
func (*Client) StartExec ¶
func (c *Client) StartExec(id string, opts StartExecOptions) error
StartExec starts a previously set up exec instance id. If opts.Detach is true, it returns after starting the exec command. Otherwise, it sets up an interactive session with the exec command.
See https://goo.gl/iQCnto for more details
func (*Client) StartExecNonBlocking ¶
func (c *Client) StartExecNonBlocking(id string, opts StartExecOptions) (CloseWaiter, error)
StartExecNonBlocking starts a previously set up exec instance id. If opts.Detach is true, it returns after starting the exec command. Otherwise, it sets up an interactive session with the exec command.
See https://goo.gl/iQCnto for more details
func (*Client) Stats ¶
func (c *Client) Stats(opts StatsOptions) (retErr error)
Stats sends container statistics for the given container to the given channel.
This function is blocking, similar to a streaming call for logs, and should be run on a separate goroutine from the caller. Note that this function will block until the given container is removed, not just exited. When finished, this function will close the given channel. Alternatively, function can be stopped by signaling on the Done channel.
See https://goo.gl/GNmLHb for more details.
func (*Client) StopContainer ¶
StopContainer stops a container, killing it after the given timeout (in seconds).
See https://goo.gl/USqsFt for more details.
func (*Client) TagImage ¶
func (c *Client) TagImage(name string, opts TagImageOptions) error
TagImage adds a tag to the image identified by the given name.
See https://goo.gl/98ZzkU for more details.
func (*Client) TopContainer ¶
TopContainer returns processes running inside a container
See https://goo.gl/Rb46aY for more details.
func (*Client) UnpauseContainer ¶
UnpauseContainer unpauses the given container.
See https://goo.gl/7dwyPA for more details.
func (*Client) UpdateContainer ¶
func (c *Client) UpdateContainer(id string, opts UpdateContainerOptions) error
UpdateContainer updates the container at ID with the options
See https://goo.gl/Y6fXUy for more details.
func (*Client) UploadToContainer ¶
func (c *Client) UploadToContainer(id string, opts UploadToContainerOptions) error
UploadToContainer uploads a tar archive to be extracted to a path in the filesystem of the container.
See https://goo.gl/Ss97HW for more details.
func (*Client) Version ¶
Version returns version information about the docker server.
See https://goo.gl/ND9R8L for more details.
func (*Client) WaitContainer ¶
WaitContainer blocks until the given container stops, return the exit code of the container status.
See https://goo.gl/Gc1rge for more details.
type CloseWaiter ¶
CloseWaiter is an interface with methods for closing the underlying resource and then waiting for it to finish processing.
type CommitContainerOptions ¶
type CommitContainerOptions struct { Container string Repository string `qs:"repo"` Tag string Message string `qs:"comment"` Author string Run *Config `qs:"-"` }
CommitContainerOptions aggregates parameters to the CommitContainer method.
See https://goo.gl/mqfoCw for more details.
type Config ¶
type Config struct { Hostname string `json:"Hostname,omitempty" yaml:"Hostname,omitempty"` Domainname string `json:"Domainname,omitempty" yaml:"Domainname,omitempty"` User string `json:"User,omitempty" yaml:"User,omitempty"` Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"` MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"` MemoryReservation int64 `json:"MemoryReservation,omitempty" yaml:"MemoryReservation,omitempty"` KernelMemory int64 `json:"KernelMemory,omitempty" yaml:"KernelMemory,omitempty"` CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"` AttachStdin bool `json:"AttachStdin,omitempty" yaml:"AttachStdin,omitempty"` AttachStdout bool `json:"AttachStdout,omitempty" yaml:"AttachStdout,omitempty"` AttachStderr bool `json:"AttachStderr,omitempty" yaml:"AttachStderr,omitempty"` PortSpecs []string `json:"PortSpecs,omitempty" yaml:"PortSpecs,omitempty"` ExposedPorts map[Port]struct{} `json:"ExposedPorts,omitempty" yaml:"ExposedPorts,omitempty"` StopSignal string `json:"StopSignal,omitempty" yaml:"StopSignal,omitempty"` Tty bool `json:"Tty,omitempty" yaml:"Tty,omitempty"` OpenStdin bool `json:"OpenStdin,omitempty" yaml:"OpenStdin,omitempty"` StdinOnce bool `json:"StdinOnce,omitempty" yaml:"StdinOnce,omitempty"` Env []string `json:"Env,omitempty" yaml:"Env,omitempty"` Cmd []string `json:"Cmd" yaml:"Cmd"` DNS []string `json:"Dns,omitempty" yaml:"Dns,omitempty"` // For Docker API v1.9 and below only Image string `json:"Image,omitempty" yaml:"Image,omitempty"` Volumes map[string]struct{} `json:"Volumes,omitempty" yaml:"Volumes,omitempty"` VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"` VolumesFrom string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"` WorkingDir string `json:"WorkingDir,omitempty" yaml:"WorkingDir,omitempty"` MacAddress string `json:"MacAddress,omitempty" yaml:"MacAddress,omitempty"` NetworkName string `json:"NetworkName,omitempty" yaml:"NetworkName,omitempty"` VirtualIP string `json:"VirtualIP,omitempty" yaml:"VirtualIP,omitempty"` Entrypoint []string `json:"Entrypoint" yaml:"Entrypoint"` NetworkDisabled bool `json:"NetworkDisabled,omitempty" yaml:"NetworkDisabled,omitempty"` SecurityOpts []string `json:"SecurityOpts,omitempty" yaml:"SecurityOpts,omitempty"` OnBuild []string `json:"OnBuild,omitempty" yaml:"OnBuild,omitempty"` Mounts []Mount `json:"Mounts,omitempty" yaml:"Mounts,omitempty"` Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty"` }
Config is the list of configuration options used when creating a container. Config does not contain the options that are specific to starting a container on a given host. Those are contained in HostConfig
type Container ¶
type Container struct { ID string `json:"Id" yaml:"Id"` Created time.Time `json:"Created,omitempty" yaml:"Created,omitempty"` Path string `json:"Path,omitempty" yaml:"Path,omitempty"` Args []string `json:"Args,omitempty" yaml:"Args,omitempty"` Config *Config `json:"Config,omitempty" yaml:"Config,omitempty"` State State `json:"State,omitempty" yaml:"State,omitempty"` Image string `json:"Image,omitempty" yaml:"Image,omitempty"` Node *SwarmNode `json:"Node,omitempty" yaml:"Node,omitempty"` NetworkSettings *NetworkSettings `json:"NetworkSettings,omitempty" yaml:"NetworkSettings,omitempty"` SysInitPath string `json:"SysInitPath,omitempty" yaml:"SysInitPath,omitempty"` ResolvConfPath string `json:"ResolvConfPath,omitempty" yaml:"ResolvConfPath,omitempty"` HostnamePath string `json:"HostnamePath,omitempty" yaml:"HostnamePath,omitempty"` HostsPath string `json:"HostsPath,omitempty" yaml:"HostsPath,omitempty"` LogPath string `json:"LogPath,omitempty" yaml:"LogPath,omitempty"` Name string `json:"Name,omitempty" yaml:"Name,omitempty"` Driver string `json:"Driver,omitempty" yaml:"Driver,omitempty"` Mounts []Mount `json:"Mounts,omitempty" yaml:"Mounts,omitempty"` Volumes map[string]string `json:"Volumes,omitempty" yaml:"Volumes,omitempty"` VolumesRW map[string]bool `json:"VolumesRW,omitempty" yaml:"VolumesRW,omitempty"` HostConfig *HostConfig `json:"HostConfig,omitempty" yaml:"HostConfig,omitempty"` ExecIDs []string `json:"ExecIDs,omitempty" yaml:"ExecIDs,omitempty"` RestartCount int `json:"RestartCount,omitempty" yaml:"RestartCount,omitempty"` AppArmorProfile string `json:"AppArmorProfile,omitempty" yaml:"AppArmorProfile,omitempty"` }
Container is the type encompasing everything about a container - its config, hostconfig, etc.
type ContainerAlreadyRunning ¶
type ContainerAlreadyRunning struct {
ID string
}
ContainerAlreadyRunning is the error returned when a given container is already running.
func (*ContainerAlreadyRunning) Error ¶
func (err *ContainerAlreadyRunning) Error() string
type ContainerNetwork ¶
type ContainerNetwork struct { MacAddress string `json:"MacAddress,omitempty" yaml:"MacAddress,omitempty"` GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen,omitempty" yaml:"GlobalIPv6PrefixLen,omitempty"` GlobalIPv6Address string `json:"GlobalIPv6Address,omitempty" yaml:"GlobalIPv6Address,omitempty"` IPv6Gateway string `json:"IPv6Gateway,omitempty" yaml:"IPv6Gateway,omitempty"` IPPrefixLen int `json:"IPPrefixLen,omitempty" yaml:"IPPrefixLen,omitempty"` IPAddress string `json:"IPAddress,omitempty" yaml:"IPAddress,omitempty"` Gateway string `json:"Gateway,omitempty" yaml:"Gateway,omitempty"` EndpointID string `json:"EndpointID,omitempty" yaml:"EndpointID,omitempty"` NetworkID string `json:"NetworkID,omitempty" yaml:"NetworkID,omitempty"` }
ContainerNetwork represents the networking settings of a container per network.
type ContainerNotRunning ¶
type ContainerNotRunning struct {
ID string
}
ContainerNotRunning is the error returned when a given container is not running.
func (*ContainerNotRunning) Error ¶
func (err *ContainerNotRunning) Error() string
type CopyFromContainerOptions ¶
type CopyFromContainerOptions struct { OutputStream io.Writer `json:"-"` Container string `json:"-"` Resource string }
CopyFromContainerOptions has been DEPRECATED, please use DownloadFromContainerOptions along with DownloadFromContainer.
See https://goo.gl/R2jevW for more details.
type CreateContainerOptions ¶
type CreateContainerOptions struct { Name string Config *Config `qs:"-"` HostConfig *HostConfig `qs:"-"` }
CreateContainerOptions specify parameters to the CreateContainer function.
See https://goo.gl/WxQzrr for more details.
type CreateExecOptions ¶
type CreateExecOptions struct { AttachStdin bool `json:"AttachStdin,omitempty" yaml:"AttachStdin,omitempty"` AttachStdout bool `json:"AttachStdout,omitempty" yaml:"AttachStdout,omitempty"` AttachStderr bool `json:"AttachStderr,omitempty" yaml:"AttachStderr,omitempty"` Tty bool `json:"Tty,omitempty" yaml:"Tty,omitempty"` Cmd []string `json:"Cmd,omitempty" yaml:"Cmd,omitempty"` Container string `json:"Container,omitempty" yaml:"Container,omitempty"` User string `json:"User,omitempty" yaml:"User,omitempty"` }
CreateExecOptions specify parameters to the CreateExecContainer function.
See https://goo.gl/1KSIb7 for more details
type CreateNetworkOptions ¶
type CreateNetworkOptions struct { Name string `json:"Name"` CheckDuplicate bool `json:"CheckDuplicate"` Driver string `json:"Driver"` IPAM IPAMOptions `json:"IPAM"` Options map[string]interface{} `json:"options"` }
CreateNetworkOptions specify parameters to the CreateNetwork function and (for now) is the expected body of the "create network" http request message
See https://goo.gl/6GugX3 for more details.
type CreateVolumeOptions ¶
CreateVolumeOptions specify parameters to the CreateVolume function.
See https://goo.gl/pBUbZ9 for more details.
type Device ¶
type Device struct { PathOnHost string `json:"PathOnHost,omitempty" yaml:"PathOnHost,omitempty"` PathInContainer string `json:"PathInContainer,omitempty" yaml:"PathInContainer,omitempty"` CgroupPermissions string `json:"CgroupPermissions,omitempty" yaml:"CgroupPermissions,omitempty"` }
Device represents a device mapping between the Docker host and the container.
type DockerInfo ¶
type DockerInfo struct { ID string Containers int ContainersRunning int ContainersPaused int ContainersStopped int Images int Driver string DriverStatus [][2]string SystemStatus [][2]string Plugins PluginsInfo MemoryLimit bool SwapLimit bool KernelMemory bool CPUCfsPeriod bool `json:"CpuCfsPeriod"` CPUCfsQuota bool `json:"CpuCfsQuota"` CPUSet bool IPv4Forwarding bool BridgeNfIptables bool BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` Debug bool NFd int OomKillDisable bool NGoroutines int SystemTime string ExecutionDriver string LoggingDriver string CgroupDriver string NEventsListener int KernelVersion string OperatingSystem string OSType string Architecture string IndexServerAddress string NCPU int MemTotal int64 DockerRootDir string HTTPProxy string `json:"HttpProxy"` HTTPSProxy string `json:"HttpsProxy"` NoProxy string Name string Labels []string ExperimentalBuild bool ServerVersion string ClusterStore string ClusterAdvertise string }
DockerInfo contains information about the Docker server
See https://goo.gl/bHUoz9 for more details.
type DownloadFromContainerOptions ¶
type DownloadFromContainerOptions struct { OutputStream io.Writer `json:"-" qs:"-"` Path string `qs:"path"` }
DownloadFromContainerOptions is the set of options that can be used when downloading resources from a container.
See https://goo.gl/KnZJDX for more details.
type Endpoint ¶
type Endpoint struct { Name string ID string `json:"EndpointID"` MacAddress string IPv4Address string IPv6Address string }
Endpoint contains network resources allocated and used for a container in a network
See https://goo.gl/6GugX3 for more details.
type EndpointConfig ¶
type EndpointConfig struct { IPAMConfig *EndpointIPAMConfig Links []string Aliases []string }
EndpointConfig stores network endpoint details
See https://goo.gl/RV7BJU for more details.
type EndpointIPAMConfig ¶
type EndpointIPAMConfig struct { IPv4Address string `json:",omitempty"` IPv6Address string `json:",omitempty"` }
EndpointIPAMConfig represents IPAM configurations for an endpoint
See https://goo.gl/RV7BJU for more details.
type Env ¶
type Env []string
Env represents a list of key-pair represented in the form KEY=VALUE.
func (*Env) Decode ¶
Decode decodes `src` as a json dictionary, and adds each decoded key-value pair to the environment.
If `src` cannot be decoded as a json dictionary, an error is returned.
func (*Env) Exists ¶
Exists checks whether the given key is defined in the internal Env representation.
func (*Env) GetBool ¶
GetBool returns a boolean representation of the given key. The key is false whenever its value if 0, no, false, none or an empty string. Any other value will be interpreted as true.
func (*Env) GetInt ¶
GetInt returns the value of the provided key, converted to int.
It the value cannot be represented as an integer, it returns -1.
func (*Env) GetInt64 ¶
GetInt64 returns the value of the provided key, converted to int64.
It the value cannot be represented as an integer, it returns -1.
func (*Env) GetJSON ¶
GetJSON unmarshals the value of the provided key in the provided iface.
iface is a value that can be provided to the json.Unmarshal function.
Example ¶
type Person struct { Name string Age int } p := Person{Name: "Gopher", Age: 4} var e docker.Env e.Set("person", `{"name":"Gopher","age":4}`) err := e.GetJSON("person", &p) if err != nil { log.Fatal(err) }
Output:
func (*Env) GetList ¶
GetList returns a list of strings matching the provided key. It handles the list as a JSON representation of a list of strings.
If the given key matches to a single string, it will return a list containing only the value that matches the key.
func (*Env) Map ¶
Map returns the map representation of the env.
Example ¶
e := docker.Env([]string{"A=1", "B=2", "C=3"}) envs := e.Map() for k, v := range envs { fmt.Printf("%s=%q\n", k, v) }
Output:
type Exec ¶
type Exec struct {
ID string `json:"Id,omitempty" yaml:"Id,omitempty"`
}
Exec is the type representing a `docker exec` instance and containing the instance ID
type ExecInspect ¶
type ExecInspect struct { ID string `json:"ID,omitempty" yaml:"ID,omitempty"` Running bool `json:"Running,omitempty" yaml:"Running,omitempty"` ExitCode int `json:"ExitCode,omitempty" yaml:"ExitCode,omitempty"` OpenStdin bool `json:"OpenStdin,omitempty" yaml:"OpenStdin,omitempty"` OpenStderr bool `json:"OpenStderr,omitempty" yaml:"OpenStderr,omitempty"` OpenStdout bool `json:"OpenStdout,omitempty" yaml:"OpenStdout,omitempty"` ProcessConfig ExecProcessConfig `json:"ProcessConfig,omitempty" yaml:"ProcessConfig,omitempty"` Container Container `json:"Container,omitempty" yaml:"Container,omitempty"` }
ExecInspect is a type with details about a exec instance, including the exit code if the command has finished running. It's returned by a api call to /exec/(id)/json
See https://goo.gl/gPtX9R for more details
type ExecProcessConfig ¶
type ExecProcessConfig struct { Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"` User string `json:"user,omitempty" yaml:"user,omitempty"` Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"` EntryPoint string `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"` Arguments []string `json:"arguments,omitempty" yaml:"arguments,omitempty"` }
ExecProcessConfig is a type describing the command associated to a Exec instance. It's used in the ExecInspect type.
type ExportContainerOptions ¶
ExportContainerOptions is the set of parameters to the ExportContainer method.
See https://goo.gl/dOkTyk for more details.
type ExportImageOptions ¶
ExportImageOptions represent the options for ExportImage Docker API call.
See https://goo.gl/le7vK8 for more details.
type ExportImagesOptions ¶
ExportImagesOptions represent the options for ExportImages Docker API call
See https://goo.gl/huC7HA for more details.
type HostConfig ¶
type HostConfig struct { Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"` CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"` CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"` GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"` ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"` LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"` Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"` PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"` Links []string `json:"Links,omitempty" yaml:"Links,omitempty"` PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty"` DNS []string `json:"Dns,omitempty" yaml:"Dns,omitempty"` // For Docker API v1.10 and above only DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"` DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"` ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"` VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"` NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"` IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"` PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"` UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty"` RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"` Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"` LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"` ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"` SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"` CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"` Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"` MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"` MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"` OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"` CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"` CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"` CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"` CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"` CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"` BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"` BlkioWeightDevice []BlockWeight `json:"BlkioWeightDevice,omitempty" yaml:"BlkioWeightDevice"` BlkioDeviceReadBps []BlockLimit `json:"BlkioDeviceReadBps,omitempty" yaml:"BlkioDeviceReadBps"` BlkioDeviceReadIOps []BlockLimit `json:"BlkioDeviceReadIOps,omitempty" yaml:"BlkioDeviceReadIOps"` BlkioDeviceWriteBps []BlockLimit `json:"BlkioDeviceWriteBps,omitempty" yaml:"BlkioDeviceWriteBps"` BlkioDeviceWriteIOps []BlockLimit `json:"BlkioDeviceWriteIOps,omitempty" yaml:"BlkioDeviceWriteIOps"` Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty"` VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"` OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty"` }
HostConfig contains the container options related to starting a container on a given host
type IPAMConfig ¶
type IPAMConfig struct { Subnet string `json:",omitempty"` IPRange string `json:",omitempty"` Gateway string `json:",omitempty"` AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` }
IPAMConfig represents IPAM configurations
See https://goo.gl/T8kRVH for more details.
type IPAMOptions ¶
type IPAMOptions struct { Driver string `json:"Driver"` Config []IPAMConfig `json:"IPAMConfig"` }
IPAMOptions controls IP Address Management when creating a network
See https://goo.gl/T8kRVH for more details.
type Image ¶
type Image struct { ID string `json:"Id" yaml:"Id"` RepoTags []string `json:"RepoTags,omitempty" yaml:"RepoTags,omitempty"` Parent string `json:"Parent,omitempty" yaml:"Parent,omitempty"` Comment string `json:"Comment,omitempty" yaml:"Comment,omitempty"` Created time.Time `json:"Created,omitempty" yaml:"Created,omitempty"` Container string `json:"Container,omitempty" yaml:"Container,omitempty"` ContainerConfig Config `json:"ContainerConfig,omitempty" yaml:"ContainerConfig,omitempty"` DockerVersion string `json:"DockerVersion,omitempty" yaml:"DockerVersion,omitempty"` Author string `json:"Author,omitempty" yaml:"Author,omitempty"` Config *Config `json:"Config,omitempty" yaml:"Config,omitempty"` Architecture string `json:"Architecture,omitempty" yaml:"Architecture,omitempty"` Size int64 `json:"Size,omitempty" yaml:"Size,omitempty"` VirtualSize int64 `json:"VirtualSize,omitempty" yaml:"VirtualSize,omitempty"` RepoDigests []string `json:"RepoDigests,omitempty" yaml:"RepoDigests,omitempty"` }
Image is the type representing a docker image and its various properties
type ImageHistory ¶
type ImageHistory struct { ID string `json:"Id" yaml:"Id"` Tags []string `json:"Tags,omitempty" yaml:"Tags,omitempty"` Created int64 `json:"Created,omitempty" yaml:"Created,omitempty"` CreatedBy string `json:"CreatedBy,omitempty" yaml:"CreatedBy,omitempty"` Size int64 `json:"Size,omitempty" yaml:"Size,omitempty"` }
ImageHistory represent a layer in an image's history returned by the ImageHistory call.
type ImagePre012 ¶
type ImagePre012 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 `json:"size,omitempty"` }
ImagePre012 serves the same purpose as the Image type except that it is for earlier versions of the Docker API (pre-012 to be specific)
type ImportImageOptions ¶
type ImportImageOptions struct { Repository string `qs:"repo"` Source string `qs:"fromSrc"` Tag string `qs:"tag"` InputStream io.Reader `qs:"-"` OutputStream io.Writer `qs:"-"` RawJSONStream bool `qs:"-"` }
ImportImageOptions present the set of informations available for importing an image from a source file or the stdin.
See https://goo.gl/iJkZjD for more details.
type KeyValuePair ¶
type KeyValuePair struct { Key string `json:"Key,omitempty" yaml:"Key,omitempty"` Value string `json:"Value,omitempty" yaml:"Value,omitempty"` }
KeyValuePair is a type for generic key/value pairs as used in the Lxc configuration
type KillContainerOptions ¶
type KillContainerOptions struct { // The ID of the container. ID string `qs:"-"` // The signal to send to the container. When omitted, Docker server // will assume SIGKILL. Signal Signal }
KillContainerOptions represents the set of options that can be used in a call to KillContainer.
See https://goo.gl/hkS9i8 for more details.
type ListContainersOptions ¶
type ListContainersOptions struct { All bool Size bool Limit int Since string Before string Filters map[string][]string }
ListContainersOptions specify parameters to the ListContainers function.
See https://goo.gl/47a6tO for more details.
type ListImagesOptions ¶
ListImagesOptions specify parameters to the ListImages function.
See https://goo.gl/xBe1u3 for more details.
type ListVolumesOptions ¶
ListVolumesOptions specify parameters to the ListVolumes function.
See https://goo.gl/FZA4BK for more details.
type LoadImageOptions ¶
LoadImageOptions represents the options for LoadImage Docker API Call
See https://goo.gl/JyClMX for more details.
type LogConfig ¶
type LogConfig struct { Type string `json:"Type,omitempty" yaml:"Type,omitempty"` Config map[string]string `json:"Config,omitempty" yaml:"Config,omitempty"` }
LogConfig defines the log driver type and the configuration for it.
type LogsOptions ¶
type LogsOptions struct { Container string `qs:"-"` OutputStream io.Writer `qs:"-"` ErrorStream io.Writer `qs:"-"` Follow bool Stdout bool Stderr bool Since int64 Timestamps bool Tail string // Use raw terminal? Usually true when the container contains a TTY. RawTerminal bool `qs:"-"` }
LogsOptions represents the set of options used when getting logs from a container.
See https://goo.gl/yl8PGm for more details.
type Mount ¶
type Mount struct { Name string Source string Destination string Driver string Mode string RW bool }
Mount represents a mount point in the container.
It has been added in the version 1.20 of the Docker API, available since Docker 1.8.
type Network ¶
type Network struct { Name string ID string `json:"Id"` Scope string Driver string IPAM IPAMOptions Containers map[string]Endpoint Options map[string]string Internal bool }
Network represents a network.
See https://goo.gl/6GugX3 for more details.
type NetworkConnectionOptions ¶
type NetworkConnectionOptions struct { Container string // EndpointConfig is only applicable to the ConnectNetwork call EndpointConfig *EndpointConfig `json:"EndpointConfig,omitempty"` // Force is only applicable to the DisconnectNetwork call Force bool }
NetworkConnectionOptions specify parameters to the ConnectNetwork and DisconnectNetwork function.
See https://goo.gl/RV7BJU for more details.
type NetworkFilterOpts ¶
NetworkFilterOpts is an aggregation of key=value that Docker uses to filter networks
type NetworkList ¶
type NetworkList struct {
Networks map[string]ContainerNetwork `json:"Networks" yaml:"Networks,omitempty"`
}
NetworkList encapsulates a map of networks, as returned by the Docker API in ListContainers.
type NetworkSettings ¶
type NetworkSettings struct { Networks map[string]ContainerNetwork `json:"Networks,omitempty" yaml:"Networks,omitempty"` IPAddress string `json:"IPAddress,omitempty" yaml:"IPAddress,omitempty"` IPPrefixLen int `json:"IPPrefixLen,omitempty" yaml:"IPPrefixLen,omitempty"` MacAddress string `json:"MacAddress,omitempty" yaml:"MacAddress,omitempty"` Gateway string `json:"Gateway,omitempty" yaml:"Gateway,omitempty"` Bridge string `json:"Bridge,omitempty" yaml:"Bridge,omitempty"` PortMapping map[string]PortMapping `json:"PortMapping,omitempty" yaml:"PortMapping,omitempty"` Ports map[Port][]PortBinding `json:"Ports,omitempty" yaml:"Ports,omitempty"` NetworkID string `json:"NetworkID,omitempty" yaml:"NetworkID,omitempty"` EndpointID string `json:"EndpointID,omitempty" yaml:"EndpointID,omitempty"` SandboxKey string `json:"SandboxKey,omitempty" yaml:"SandboxKey,omitempty"` GlobalIPv6Address string `json:"GlobalIPv6Address,omitempty" yaml:"GlobalIPv6Address,omitempty"` GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen,omitempty" yaml:"GlobalIPv6PrefixLen,omitempty"` IPv6Gateway string `json:"IPv6Gateway,omitempty" yaml:"IPv6Gateway,omitempty"` LinkLocalIPv6Address string `json:"LinkLocalIPv6Address,omitempty" yaml:"LinkLocalIPv6Address,omitempty"` LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen,omitempty" yaml:"LinkLocalIPv6PrefixLen,omitempty"` SecondaryIPAddresses []string `json:"SecondaryIPAddresses,omitempty" yaml:"SecondaryIPAddresses,omitempty"` SecondaryIPv6Addresses []string `json:"SecondaryIPv6Addresses,omitempty" yaml:"SecondaryIPv6Addresses,omitempty"` }
NetworkSettings contains network-related information about a container
func (*NetworkSettings) PortMappingAPI ¶
func (settings *NetworkSettings) PortMappingAPI() []APIPort
PortMappingAPI translates the port mappings as contained in NetworkSettings into the format in which they would appear when returned by the API
type NetworkStats ¶
type NetworkStats struct { RxDropped uint64 `json:"rx_dropped,omitempty" yaml:"rx_dropped,omitempty"` RxBytes uint64 `json:"rx_bytes,omitempty" yaml:"rx_bytes,omitempty"` RxErrors uint64 `json:"rx_errors,omitempty" yaml:"rx_errors,omitempty"` TxPackets uint64 `json:"tx_packets,omitempty" yaml:"tx_packets,omitempty"` TxDropped uint64 `json:"tx_dropped,omitempty" yaml:"tx_dropped,omitempty"` RxPackets uint64 `json:"rx_packets,omitempty" yaml:"rx_packets,omitempty"` TxErrors uint64 `json:"tx_errors,omitempty" yaml:"tx_errors,omitempty"` TxBytes uint64 `json:"tx_bytes,omitempty" yaml:"tx_bytes,omitempty"` }
NetworkStats is a stats entry for network stats
type NoSuchContainer ¶
NoSuchContainer is the error returned when a given container does not exist.
func (*NoSuchContainer) Error ¶
func (err *NoSuchContainer) Error() string
type NoSuchExec ¶
type NoSuchExec struct {
ID string
}
NoSuchExec is the error returned when a given exec instance does not exist.
func (*NoSuchExec) Error ¶
func (err *NoSuchExec) Error() string
type NoSuchNetwork ¶
type NoSuchNetwork struct {
ID string
}
NoSuchNetwork is the error returned when a given network does not exist.
func (*NoSuchNetwork) Error ¶
func (err *NoSuchNetwork) Error() string
type NoSuchNetworkOrContainer ¶
NoSuchNetworkOrContainer is the error returned when a given network or container does not exist.
func (*NoSuchNetworkOrContainer) Error ¶
func (err *NoSuchNetworkOrContainer) Error() string
type PluginsInfo ¶
type PluginsInfo struct { // List of Volume plugins registered Volume []string // List of Network plugins registered Network []string // List of Authorization plugins registered Authorization []string }
PluginsInfo is a struct with the plugins registered with the docker daemon
for more information, see: https://goo.gl/bHUoz9
type Port ¶
type Port string
Port represents the port number and the protocol, in the form <number>/<protocol>. For example: 80/tcp.
type PortBinding ¶
type PortBinding struct { HostIP string `json:"HostIP,omitempty" yaml:"HostIP,omitempty"` HostPort string `json:"HostPort,omitempty" yaml:"HostPort,omitempty"` }
PortBinding represents the host/container port mapping as returned in the `docker inspect` json
type PortMapping ¶
PortMapping represents a deprecated field in the `docker inspect` output, and its value as found in NetworkSettings should always be nil
type PullImageOptions ¶
type PullImageOptions struct { Repository string `qs:"fromImage"` Registry string Tag string OutputStream io.Writer `qs:"-"` RawJSONStream bool `qs:"-"` }
PullImageOptions present the set of options available for pulling an image from a registry.
See https://goo.gl/iJkZjD for more details.
type PushImageOptions ¶
type PushImageOptions struct { // Name of the image Name string // Tag of the image Tag string // Registry server to push the image Registry string OutputStream io.Writer `qs:"-"` RawJSONStream bool `qs:"-"` }
PushImageOptions represents options to use in the PushImage method.
See https://goo.gl/zPtZaT for more details.
type RemoveContainerOptions ¶
type RemoveContainerOptions struct { // The ID of the container. ID string `qs:"-"` // A flag that indicates whether Docker should remove the volumes // associated to the container. RemoveVolumes bool `qs:"v"` // A flag that indicates whether Docker should remove the container // even if it is currently running. Force bool }
RemoveContainerOptions encapsulates options to remove a container.
See https://goo.gl/RQyX62 for more details.
type RemoveImageOptions ¶
RemoveImageOptions present the set of options available for removing an image from a registry.
See https://goo.gl/V3ZWnK for more details.
type RenameContainerOptions ¶
type RenameContainerOptions struct { // ID of container to rename ID string `qs:"-"` // New name Name string `json:"name,omitempty" yaml:"name,omitempty"` }
RenameContainerOptions specify parameters to the RenameContainer function.
See https://goo.gl/laSOIy for more details.
type RestartPolicy ¶
type RestartPolicy struct { Name string `json:"Name,omitempty" yaml:"Name,omitempty"` MaximumRetryCount int `json:"MaximumRetryCount,omitempty" yaml:"MaximumRetryCount,omitempty"` }
RestartPolicy represents the policy for automatically restarting a container.
Possible values are:
- always: the docker daemon will always restart the container
- on-failure: the docker daemon will restart the container on failures, at most MaximumRetryCount times
- no: the docker daemon will not restart the container automatically
func AlwaysRestart ¶
func AlwaysRestart() RestartPolicy
AlwaysRestart returns a restart policy that tells the Docker daemon to always restart the container.
func NeverRestart ¶
func NeverRestart() RestartPolicy
NeverRestart returns a restart policy that tells the Docker daemon to never restart the container on failures.
func RestartOnFailure ¶
func RestartOnFailure(maxRetry int) RestartPolicy
RestartOnFailure returns a restart policy that tells the Docker daemon to restart the container on failures, trying at most maxRetry times.
type Signal ¶
type Signal int
Signal represents a signal that can be send to the container on KillContainer call.
type StartExecOptions ¶
type StartExecOptions struct { Detach bool `json:"Detach,omitempty" yaml:"Detach,omitempty"` Tty bool `json:"Tty,omitempty" yaml:"Tty,omitempty"` InputStream io.Reader `qs:"-"` OutputStream io.Writer `qs:"-"` ErrorStream io.Writer `qs:"-"` // Use raw terminal? Usually true when the container contains a TTY. RawTerminal bool `qs:"-"` // If set, after a successful connect, a sentinel will be sent and then the // client will block on receive before continuing. // // It must be an unbuffered channel. Using a buffered channel can lead // to unexpected behavior. Success chan struct{} `json:"-"` }
StartExecOptions specify parameters to the StartExecContainer function.
See https://goo.gl/iQCnto for more details
type State ¶
type State struct { Running bool `json:"Running,omitempty" yaml:"Running,omitempty"` Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"` Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"` OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"` Pid int `json:"Pid,omitempty" yaml:"Pid,omitempty"` ExitCode int `json:"ExitCode,omitempty" yaml:"ExitCode,omitempty"` Error string `json:"Error,omitempty" yaml:"Error,omitempty"` StartedAt time.Time `json:"StartedAt,omitempty" yaml:"StartedAt,omitempty"` FinishedAt time.Time `json:"FinishedAt,omitempty" yaml:"FinishedAt,omitempty"` }
State represents the state of a container.
type Stats ¶
type Stats struct { Read time.Time `json:"read,omitempty" yaml:"read,omitempty"` Network NetworkStats `json:"network,omitempty" yaml:"network,omitempty"` Networks map[string]NetworkStats `json:"networks,omitempty" yaml:"networks,omitempty"` MemoryStats struct { Stats struct { TotalPgmafault uint64 `json:"total_pgmafault,omitempty" yaml:"total_pgmafault,omitempty"` Cache uint64 `json:"cache,omitempty" yaml:"cache,omitempty"` MappedFile uint64 `json:"mapped_file,omitempty" yaml:"mapped_file,omitempty"` TotalInactiveFile uint64 `json:"total_inactive_file,omitempty" yaml:"total_inactive_file,omitempty"` Pgpgout uint64 `json:"pgpgout,omitempty" yaml:"pgpgout,omitempty"` Rss uint64 `json:"rss,omitempty" yaml:"rss,omitempty"` TotalMappedFile uint64 `json:"total_mapped_file,omitempty" yaml:"total_mapped_file,omitempty"` Writeback uint64 `json:"writeback,omitempty" yaml:"writeback,omitempty"` Unevictable uint64 `json:"unevictable,omitempty" yaml:"unevictable,omitempty"` Pgpgin uint64 `json:"pgpgin,omitempty" yaml:"pgpgin,omitempty"` TotalUnevictable uint64 `json:"total_unevictable,omitempty" yaml:"total_unevictable,omitempty"` Pgmajfault uint64 `json:"pgmajfault,omitempty" yaml:"pgmajfault,omitempty"` TotalRss uint64 `json:"total_rss,omitempty" yaml:"total_rss,omitempty"` TotalRssHuge uint64 `json:"total_rss_huge,omitempty" yaml:"total_rss_huge,omitempty"` TotalWriteback uint64 `json:"total_writeback,omitempty" yaml:"total_writeback,omitempty"` TotalInactiveAnon uint64 `json:"total_inactive_anon,omitempty" yaml:"total_inactive_anon,omitempty"` RssHuge uint64 `json:"rss_huge,omitempty" yaml:"rss_huge,omitempty"` HierarchicalMemoryLimit uint64 `json:"hierarchical_memory_limit,omitempty" yaml:"hierarchical_memory_limit,omitempty"` TotalPgfault uint64 `json:"total_pgfault,omitempty" yaml:"total_pgfault,omitempty"` TotalActiveFile uint64 `json:"total_active_file,omitempty" yaml:"total_active_file,omitempty"` ActiveAnon uint64 `json:"active_anon,omitempty" yaml:"active_anon,omitempty"` TotalActiveAnon uint64 `json:"total_active_anon,omitempty" yaml:"total_active_anon,omitempty"` TotalPgpgout uint64 `json:"total_pgpgout,omitempty" yaml:"total_pgpgout,omitempty"` TotalCache uint64 `json:"total_cache,omitempty" yaml:"total_cache,omitempty"` InactiveAnon uint64 `json:"inactive_anon,omitempty" yaml:"inactive_anon,omitempty"` ActiveFile uint64 `json:"active_file,omitempty" yaml:"active_file,omitempty"` Pgfault uint64 `json:"pgfault,omitempty" yaml:"pgfault,omitempty"` InactiveFile uint64 `json:"inactive_file,omitempty" yaml:"inactive_file,omitempty"` TotalPgpgin uint64 `json:"total_pgpgin,omitempty" yaml:"total_pgpgin,omitempty"` HierarchicalMemswLimit uint64 `json:"hierarchical_memsw_limit,omitempty" yaml:"hierarchical_memsw_limit,omitempty"` Swap uint64 `json:"swap,omitempty" yaml:"swap,omitempty"` } `json:"stats,omitempty" yaml:"stats,omitempty"` MaxUsage uint64 `json:"max_usage,omitempty" yaml:"max_usage,omitempty"` Usage uint64 `json:"usage,omitempty" yaml:"usage,omitempty"` Failcnt uint64 `json:"failcnt,omitempty" yaml:"failcnt,omitempty"` Limit uint64 `json:"limit,omitempty" yaml:"limit,omitempty"` } `json:"memory_stats,omitempty" yaml:"memory_stats,omitempty"` BlkioStats struct { IOServiceBytesRecursive []BlkioStatsEntry `json:"io_service_bytes_recursive,omitempty" yaml:"io_service_bytes_recursive,omitempty"` IOServicedRecursive []BlkioStatsEntry `json:"io_serviced_recursive,omitempty" yaml:"io_serviced_recursive,omitempty"` IOQueueRecursive []BlkioStatsEntry `json:"io_queue_recursive,omitempty" yaml:"io_queue_recursive,omitempty"` IOServiceTimeRecursive []BlkioStatsEntry `json:"io_service_time_recursive,omitempty" yaml:"io_service_time_recursive,omitempty"` IOWaitTimeRecursive []BlkioStatsEntry `json:"io_wait_time_recursive,omitempty" yaml:"io_wait_time_recursive,omitempty"` IOMergedRecursive []BlkioStatsEntry `json:"io_merged_recursive,omitempty" yaml:"io_merged_recursive,omitempty"` IOTimeRecursive []BlkioStatsEntry `json:"io_time_recursive,omitempty" yaml:"io_time_recursive,omitempty"` SectorsRecursive []BlkioStatsEntry `json:"sectors_recursive,omitempty" yaml:"sectors_recursive,omitempty"` } `json:"blkio_stats,omitempty" yaml:"blkio_stats,omitempty"` CPUStats CPUStats `json:"cpu_stats,omitempty" yaml:"cpu_stats,omitempty"` PreCPUStats CPUStats `json:"precpu_stats,omitempty"` }
Stats represents container statistics, returned by /containers/<id>/stats.
See https://goo.gl/GNmLHb for more details.
type StatsOptions ¶
type StatsOptions struct { ID string Stats chan<- *Stats Stream bool // A flag that enables stopping the stats operation Done <-chan bool // Initial connection timeout Timeout time.Duration }
StatsOptions specify parameters to the Stats function.
See https://goo.gl/GNmLHb for more details.
type SwarmNode ¶
type SwarmNode struct { ID string `json:"ID,omitempty" yaml:"ID,omitempty"` IP string `json:"IP,omitempty" yaml:"IP,omitempty"` Addr string `json:"Addr,omitempty" yaml:"Addr,omitempty"` Name string `json:"Name,omitempty" yaml:"Name,omitempty"` CPUs int64 `json:"CPUs,omitempty" yaml:"CPUs,omitempty"` Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"` Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty"` }
SwarmNode containers information about which Swarm node the container is on
type TagImageOptions ¶
TagImageOptions present the set of options to tag an image.
See https://goo.gl/98ZzkU for more details.
type TopResult ¶
TopResult represents the list of processes running in a container, as returned by /containers/<id>/top.
See https://goo.gl/Rb46aY for more details.
type ULimit ¶
type ULimit struct { Name string `json:"Name,omitempty" yaml:"Name,omitempty"` Soft int64 `json:"Soft,omitempty" yaml:"Soft,omitempty"` Hard int64 `json:"Hard,omitempty" yaml:"Hard,omitempty"` }
ULimit defines system-wide resource limitations This can help a lot in system administration, e.g. when a user starts too many processes and therefore makes the system unresponsive for other users.
type UpdateContainerOptions ¶
type UpdateContainerOptions struct { BlkioWeight int `json:"BlkioWeight"` CPUPeriod int `json:"CpuPeriod"` CPUQuota int `json:"CpuQuota"` CpusetCpus string `json:"CpusetCpus"` CpusetMems string `json:"CpusetMems"` Memory int `json:"Memory"` MemorySwap int `json:"MemorySwap"` MemoryReservation int `json:"MemoryReservation"` KernelMemory int `json:"KernelMemory"` }
UpdateContainerOptions specify parameters to the UpdateContainer function.
See https://goo.gl/Y6fXUy for more details.
type UploadToContainerOptions ¶
type UploadToContainerOptions struct { InputStream io.Reader `json:"-" qs:"-"` Path string `qs:"path"` NoOverwriteDirNonDir bool `qs:"noOverwriteDirNonDir"` }
UploadToContainerOptions is the set of options that can be used when uploading an archive into a container.
See https://goo.gl/Ss97HW for more details.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
external
|
|
github.com/Sirupsen/logrus
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
|
Package logrus is a structured logger for Go, completely API compatible with the standard library logger. |
github.com/docker/docker/pkg/pools
Package pools provides a collection of pools which provide various data types with buffers.
|
Package pools provides a collection of pools which provide various data types with buffers. |
github.com/docker/go-units
Package units provides helper function to parse and print size and time units in human-readable format.
|
Package units provides helper function to parse and print size and time units in human-readable format. |
github.com/gorilla/context
Package context stores values shared during a request lifetime.
|
Package context stores values shared during a request lifetime. |
github.com/gorilla/mux
Package gorilla/mux implements a request router and dispatcher.
|
Package gorilla/mux implements a request router and dispatcher. |
golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
|
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes. |
golang.org/x/sys/unix
Package unix contains an interface to the low-level operating system primitives.
|
Package unix contains an interface to the low-level operating system primitives. |
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
|
Package testing provides a fake implementation of the Docker API, useful for testing purpose. |