Documentation
¶
Index ¶
- Constants
- Variables
- func BytesSize(size float64) string
- func EnableDebug()
- func EnableExitOnFatal()
- func FromHumanSize(size string) (int64, error)
- func HumanSize(size float64) string
- func IsNotFound(err error) bool
- func IsServerInternalError(err error) bool
- func ParseBytesSize(size string) (int64, error)
- func RAMInBytes(size string) (int64, error)
- func UnwrappedLogger() *log.Logger
- type Actor
- type AuthConfig
- type BlkioStatEntry
- type BlkioStats
- type Container
- type ContainerConfig
- type ContainerDetail
- type ContainerState
- type CpuStats
- type CpuUsage
- type Device
- type DockerClient
- func NewDockerClient(daemonUrl string, tlsConfig *tls.Config, apiVersion ...string) (*DockerClient, error)
- func NewDockerClientTimeout(daemonUrl string, tlsConfig *tls.Config, timeout time.Duration, ...) (*DockerClient, error)
- func NewSwarmClient(swarmUrl string, tlsConfig *tls.Config, apiVersion ...string) (*DockerClient, error)
- func NewSwarmClientTimeout(swarmUrl string, tlsConfig *tls.Config, timeout time.Duration, ...) (*DockerClient, error)
- func (client *DockerClient) ConnectContainer(networkName string, id string, ipAddr string) error
- func (client *DockerClient) ContainerChanges(id string) ([]FsChange, error)
- func (client *DockerClient) ContainerLogs(id string, stdout, stderr, timestamps bool, tail ...int) ([]LogEntry, error)
- func (client *DockerClient) ContainerProcesses(id string, psArgs ...string) (Processes, error)
- func (client *DockerClient) ContainerStats(id string) (Stats, error)
- func (client *DockerClient) CreateContainer(containerConf ContainerConfig, hostConf HostConfig, ...) (string, error)
- func (client *DockerClient) CreateExec(id string, execConfig ExecConfig) (string, error)
- func (client *DockerClient) DisconnectContainer(networkName string, id string, force bool) error
- func (client *DockerClient) EventsSince(filters string, since time.Duration, until ...time.Duration) ([]Event, error)
- func (client *DockerClient) Info() (DockerInfo, error)
- func (client *DockerClient) InspectContainer(id string) (ContainerDetail, error)
- func (client *DockerClient) InspectImage(name string) (ImageDetail, error)
- func (client *DockerClient) IsSwarm() bool
- func (client *DockerClient) KillContainer(id string, signal ...string) error
- func (client *DockerClient) ListContainers(showAll, showSize bool, filters ...string) ([]Container, error)
- func (client *DockerClient) ListImages(showAll bool, filters ...string) ([]Image, error)
- func (client *DockerClient) MonitorEvents(filters string, callback EventCallback) int64
- func (client *DockerClient) MonitorStats(containerId string, callback StatsCallback) int64
- func (client *DockerClient) PauseContainer(id string) error
- func (client *DockerClient) Ping() (bool, error)
- func (client *DockerClient) PullImage(name string, tag string, authConfig ...AuthConfig) error
- func (client *DockerClient) PushImage(name string, repo string, tag string, authConfig ...AuthConfig) error
- func (client *DockerClient) RemoveContainer(id string, force, volumes bool) error
- func (client *DockerClient) RemoveImage(name string, force, noprune bool) error
- func (client *DockerClient) RenameContainer(id string, name string) error
- func (client *DockerClient) RestartContainer(id string, timeout ...int) error
- func (client *DockerClient) StartContainer(id string) error
- func (client *DockerClient) StartExec(execId string, detach, tty bool) ([]byte, error)
- func (client *DockerClient) StopContainer(id string, timeout ...int) error
- func (client *DockerClient) StopMonitor(monitorId int64)
- func (client *DockerClient) SwarmInfo() (SwarmInfo, error)
- func (client *DockerClient) TagImage(name string, repo string, tag string, force bool) error
- func (client *DockerClient) UnpauseContainer(id string) error
- func (client *DockerClient) UpdateContainer(id string, config interface{}) error
- func (client *DockerClient) Version() (Version, error)
- func (client *DockerClient) WaitContainer(id string) (int, error)
- type DockerInfo
- type EndpointConfig
- type Error
- type Event
- type EventCallback
- type ExecConfig
- type FsChange
- type GraphDriverData
- type Health
- type HealthConfig
- type HostConfig
- type IPAMConfig
- type Image
- type ImageDetail
- type LogConfig
- type LogEntry
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) DebugV(v interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- type MemoryStats
- type NetworkOptions
- type NetworkSettings
- type NetworkStats
- type NetworkingConfig
- type Networks
- type Port
- type PortBinding
- type Processes
- type RequestConfig
- type Resources
- type RestartPolicy
- type Stats
- type StatsCallback
- type SwarmInfo
- type SwarmNode
- type SwarmNodeInfo
- type ThrottleDevice
- type ThrottlingData
- type Ulimit
- type Version
- type WeightDevice
Constants ¶
const ( DockerEventCreate = "create" DockerEventDestroy = "destroy" DockerEventDie = "die" DockerEventExecCreate = "exec_create" DockerEventExecStart = "exec_start" DockerEventExport = "export" DockerEventKill = "kill" DockerEventOOM = "oom" DockerEventPause = "pause" DockerEventRestart = "restart" DockerEventStart = "start" DockerEventStop = "stop" DockerEventUnpause = "unpause" DockerEventRename = "rename" DockerEventImageUntag = "untag" DockerEventImageDelete = "delete" // ContainerEventType is the event type that containers generate ContainerEventType = "container" // DaemonEventType is the event type that daemon generate DaemonEventType = "daemon" // ImageEventType is the event type that images generate ImageEventType = "image" // NetworkEventType is the event type that networks generate NetworkEventType = "network" // PluginEventType is the event type that plugins generate PluginEventType = "plugin" // VolumeEventType is the event type that volumes generate VolumeEventType = "volume" )
const ( KB = 1000 MB = 1000 * KB GB = 1000 * MB TB = 1000 * GB PB = 1000 * TB KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB PiB = 1024 * TiB )
See: http://en.wikipedia.org/wiki/Binary_prefix
const (
ImagePuSecs = 100 * time.Second // 1000M / (10M/s)
)
Variables ¶
var ( ErrInvalidHeader = errors.New("Invalid header for docker log") ErrInvalidData = errors.New("Invalid data for docker log") )
Functions ¶
func EnableDebug ¶
func EnableDebug()
func EnableExitOnFatal ¶
func EnableExitOnFatal()
func FromHumanSize ¶
FromHumanSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB")
func HumanSize ¶
HumanSize returns a human-readable approximation of a size using SI standard (eg. "44kB", "17MB")
func IsNotFound ¶
func IsServerInternalError ¶
func ParseBytesSize ¶
ParseBytesSize parse a string like "1.795 GiB" into an int64
func RAMInBytes ¶
RAMInBytes parses a human-readable string representing an amount of RAM in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and returns the number of bytes, or -1 if the string is unparseable. Units are case-insensitive, and the 'b' suffix is optional.
func UnwrappedLogger ¶
Types ¶
type Actor ¶
Actor describes something that generates events, like a container, or a network, or a volume. It has a defined name and a set or attributes. The container attributes are its labels, other actors can generate these attributes from other properties.
type AuthConfig ¶
type AuthConfig struct {
UserName string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Email string `json:"email,omitempty"`
}
func (AuthConfig) Encode ¶
func (auth AuthConfig) Encode() string
type BlkioStatEntry ¶
type BlkioStats ¶
type BlkioStats struct {
IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"`
IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"`
IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"`
IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"`
IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"`
IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"`
IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"`
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"`
}
type Container ¶
type Container struct {
Command string
Created int64
Id string
Image string
Labels map[string]string
Names []string
Ports []Port
SizeRootFs int64
SizeRw int64
Status string
}
Container defines basic container information for ListContainers
type ContainerConfig ¶
type ContainerConfig struct {
AttachStderr bool
AttachStdin bool
AttachStdout bool
Cmd []string
Domainname string
Entrypoint []string
Env []string
ExposedPorts map[string]struct{}
Healthcheck *HealthConfig `json:",omitempty"`
Hostname string
Image string
Labels map[string]string
MacAddress string
NetworkDisabled bool
OnBuild []string
OpenStdin bool
PortSpecs []string
StdinOnce bool
Tty bool
User string
VolumeDriver string
Volumes map[string]struct{}
WorkingDir string
}
ContainerConfig defines basic container creation data stucture
type ContainerDetail ¶
type ContainerDetail struct {
AppArmorProfile string
Args []string
Config ContainerConfig
Created time.Time
Driver string
ExecDriver string
ExecIDs []string
GraphDriver GraphDriverData
HostConfig HostConfig
HostnamePath string
HostsPath string
Id string
Image string
LogPath string
MountLabel string
Name string
NetworkSettings NetworkSettings
Path string
ProcessLabel string
ResolvConfPath string
RestartCount int
State ContainerState
Volumes map[string]string
VolumesRW map[string]bool
Node SwarmNode // swarm api
}
ContainerDetail defines the detail data of the container from inspection, including the swarm node infor
type ContainerState ¶
type ContainerState struct {
Dead bool
Error string
ExitCode int
FinishedAt time.Time
OOMKilled bool
Paused bool
Pid int64
Restarting bool
Running bool
StartedAt time.Time
Health *Health
}
ContainerState defines container running state from inspection
type CpuStats ¶
type CpuStats struct {
CpuUsage CpuUsage `json:"cpu_usage"`
SystemUsage uint64 `json:"system_cpu_usage"`
ThrottlingData ThrottlingData `json:"throttling_data"`
}
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
func NewDockerClient ¶
func NewDockerClientTimeout ¶
func NewSwarmClient ¶
func NewSwarmClientTimeout ¶
func (*DockerClient) ConnectContainer ¶
func (client *DockerClient) ConnectContainer(networkName string, id string, ipAddr string) error
func (*DockerClient) ContainerChanges ¶
func (client *DockerClient) ContainerChanges(id string) ([]FsChange, error)
func (*DockerClient) ContainerLogs ¶
func (*DockerClient) ContainerProcesses ¶
func (client *DockerClient) ContainerProcesses(id string, psArgs ...string) (Processes, error)
func (*DockerClient) ContainerStats ¶
func (client *DockerClient) ContainerStats(id string) (Stats, error)
func (*DockerClient) CreateContainer ¶
func (client *DockerClient) CreateContainer(containerConf ContainerConfig, hostConf HostConfig, networkingConf NetworkingConfig, name ...string) (string, error)
func (*DockerClient) CreateExec ¶
func (client *DockerClient) CreateExec(id string, execConfig ExecConfig) (string, error)
func (*DockerClient) DisconnectContainer ¶
func (client *DockerClient) DisconnectContainer(networkName string, id string, force bool) error
func (*DockerClient) EventsSince ¶
func (*DockerClient) Info ¶
func (client *DockerClient) Info() (DockerInfo, error)
func (*DockerClient) InspectContainer ¶
func (client *DockerClient) InspectContainer(id string) (ContainerDetail, error)
InspectContainer returns container detail data with container id
func (*DockerClient) InspectImage ¶
func (client *DockerClient) InspectImage(name string) (ImageDetail, error)
func (*DockerClient) IsSwarm ¶
func (client *DockerClient) IsSwarm() bool
func (*DockerClient) KillContainer ¶
func (client *DockerClient) KillContainer(id string, signal ...string) error
func (*DockerClient) ListContainers ¶
func (client *DockerClient) ListContainers(showAll, showSize bool, filters ...string) ([]Container, error)
ListContainers returns containers data, showAll flag defines if you want to show all the containers including the stopped ones
func (*DockerClient) ListImages ¶
func (client *DockerClient) ListImages(showAll bool, filters ...string) ([]Image, error)
func (*DockerClient) MonitorEvents ¶
func (client *DockerClient) MonitorEvents(filters string, callback EventCallback) int64
func (*DockerClient) MonitorStats ¶
func (client *DockerClient) MonitorStats(containerId string, callback StatsCallback) int64
func (*DockerClient) PauseContainer ¶
func (client *DockerClient) PauseContainer(id string) error
func (*DockerClient) Ping ¶
func (client *DockerClient) Ping() (bool, error)
func (*DockerClient) PullImage ¶
func (client *DockerClient) PullImage(name string, tag string, authConfig ...AuthConfig) error
func (*DockerClient) PushImage ¶
func (client *DockerClient) PushImage(name string, repo string, tag string, authConfig ...AuthConfig) error
func (*DockerClient) RemoveContainer ¶
func (client *DockerClient) RemoveContainer(id string, force, volumes bool) error
func (*DockerClient) RemoveImage ¶
func (client *DockerClient) RemoveImage(name string, force, noprune bool) error
func (*DockerClient) RenameContainer ¶
func (client *DockerClient) RenameContainer(id string, name string) error
func (*DockerClient) RestartContainer ¶
func (client *DockerClient) RestartContainer(id string, timeout ...int) error
func (*DockerClient) StartContainer ¶
func (client *DockerClient) StartContainer(id string) error
func (*DockerClient) StartExec ¶
func (client *DockerClient) StartExec(execId string, detach, tty bool) ([]byte, error)
func (*DockerClient) StopContainer ¶
func (client *DockerClient) StopContainer(id string, timeout ...int) error
func (*DockerClient) StopMonitor ¶
func (client *DockerClient) StopMonitor(monitorId int64)
func (*DockerClient) SwarmInfo ¶
func (client *DockerClient) SwarmInfo() (SwarmInfo, error)
func (*DockerClient) UnpauseContainer ¶
func (client *DockerClient) UnpauseContainer(id string) error
func (*DockerClient) UpdateContainer ¶
func (client *DockerClient) UpdateContainer(id string, config interface{}) error
func (*DockerClient) Version ¶
func (client *DockerClient) Version() (Version, error)
func (*DockerClient) WaitContainer ¶
func (client *DockerClient) WaitContainer(id string) (int, error)
This will block the call routine until the container is stopped
type DockerInfo ¶
type DockerInfo struct {
Containers int64
DockerRootDir string
Driver string
DriverStatus [][2]string
SystemStatus [][2]string
ExecutionDriver string
ID string
//IPv4Forwarding int
Images int64
IndexServerAddress string
InitPath string
InitSha1 string
KernelVersion string
Labels []string
MemTotal int64
//MemoryLimit int
NCPU int64
NEventsListener int64
NFd int64
NGoroutines int64
Name string
OperatingSystem string
//SwapLimit int
HttpProxy string // v1.18
HttpsProxy string // v1.18
NoProxy string // v1.18
SystemTime time.Time // v1.18
}
type EndpointConfig ¶
type EndpointConfig struct {
IPAMConfig IPAMConfig
}
type Event ¶
type Event struct {
// Deprecated information from JSONMessage.
// With data only in container events.
Status string `json:"status,omitempty"`
ID string `json:"id,omitempty"`
From string `json:"from,omitempty"`
Type string
Action string
Actor Actor
Time int64 `json:"time,omitempty"`
TimeNano int64 `json:"timeNano,omitempty"`
Node SwarmNode `json:"node,omitempty"`
}
Message represents the information an event contains
type EventCallback ¶
type ExecConfig ¶
type GraphDriverData ¶
type HealthConfig ¶
type HealthConfig struct {
// Test is the test to perform to check that the container is healthy.
// An empty slice means to inherit the default.
// The options are:
// {} : inherit healthcheck
// {"NONE"} : disable healthcheck
// {"CMD", args...} : exec arguments directly
// {"CMD-SHELL", command} : run command with system's default shell
Test []string `json:",omitempty"`
// Zero means to inherit. Durations are expressed as integer nanoseconds.
Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down.
// Retries is the number of consecutive failures needed to consider a container as unhealthy.
// Zero means inherit.
Retries int `json:",omitempty"`
}
type HostConfig ¶
type HostConfig struct {
Binds []string
CapAdd []string
CapDrop []string
ContainerIDFile string
Dns []string
DnsSearch []string
ExtraHosts []string
IpcMode string
Links []string
LxcConf []map[string]string
NetworkMode string
PidMode string
PortBindings map[string][]PortBinding
Privileged bool
PublishAllPorts bool
ReadonlyRootfs bool
RestartPolicy RestartPolicy
SecurityOpt []string
VolumesFrom []string
LogConfig LogConfig // 1.18
// Contains container's resources (cgroups, ulimits)
Resources
}
HostConfig defines basic host configuration for container to run
type IPAMConfig ¶
type ImageDetail ¶
type MemoryStats ¶
type NetworkOptions ¶
type NetworkOptions struct {
Container string
EndpointConfig EndpointConfig
Force bool
}
type NetworkSettings ¶
type NetworkStats ¶
type NetworkStats struct {
RxBytes uint64 `json:"rx_bytes"`
RxPackets uint64 `json:"rx_packets"`
RxErrors uint64 `json:"rx_errors"`
RxDropped uint64 `json:"rx_dropped"`
TxBytes uint64 `json:"tx_bytes"`
TxPackets uint64 `json:"tx_packets"`
TxErrors uint64 `json:"tx_errors"`
TxDropped uint64 `json:"tx_dropped"`
}
type NetworkingConfig ¶
type NetworkingConfig struct {
EndpointsConfig map[string]EndpointConfig
}
type PortBinding ¶
type RequestConfig ¶
type Resources ¶
type Resources struct {
// Applicable to all platforms
Memory int64 // Memory limit (in bytes)
// Applicable to UNIX platforms
CgroupParent string // Parent cgroup.
BlkioWeight uint16 // Block IO weight (relative weight vs. other containers)
BlkioWeightDevice []*WeightDevice
BlkioDeviceReadBps []*ThrottleDevice
BlkioDeviceWriteBps []*ThrottleDevice
BlkioDeviceReadIOps []*ThrottleDevice
BlkioDeviceWriteIOps []*ThrottleDevice
CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period
CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
CpusetCpus string // CpusetCpus 0-2, 0,1
CpusetMems string // CpusetMems 0-2, 0,1
Devices []Device
DiskQuota int64 // Disk limit (in bytes)
KernelMemory int64 // Kernel memory limit (in bytes)
MemoryReservation int64 // Memory soft limit (in bytes)
MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap
MemorySwappiness *int64 // Tuning container memory swappiness behaviour
OomKillDisable *bool // Whether to disable OOM Killer or not
PidsLimit int64 // Setting pids limit for a container
Ulimits []*Ulimit // List of ulimits to be set in the container
// Applicable to Windows
CPUCount int64 `json:"CpuCount"` // CPU count
CPUPercent int64 `json:"CpuPercent"` // CPU percent
IOMaximumIOps uint64 // Maximum IOps for the container system drive
IOMaximumBandwidth uint64 // Maximum IO in bytes per second for the container system drive
}
Resources contains container's resources (cgroups config, ulimits...)
type RestartPolicy ¶
type Stats ¶
type Stats struct {
Read time.Time `json:"read"`
NetworkStats NetworkStats `json:"network"`
CpuStats CpuStats `json:"cpu_stats"`
MemoryStats MemoryStats `json:"memory_stats"`
BlkioStats BlkioStats `json:"blkio_stats"`
}
type StatsCallback ¶
type SwarmInfo ¶
type SwarmInfo struct {
Role string
Containers int64
Strategy string
Filters string
Nodes []SwarmNodeInfo
}
type SwarmNode ¶
type SwarmNode struct {
Name string
ID string
Addr string
IP string
Cpus int
Memory int64
Labels map[string]string
}
SwarmNode defines the swarm api data for container running node
type SwarmNodeInfo ¶
type ThrottleDevice ¶
ThrottleDevice is a structure that holds device:rate_per_second pair
func (*ThrottleDevice) String ¶
func (t *ThrottleDevice) String() string
type ThrottlingData ¶
type WeightDevice ¶
WeightDevice is a structure that holds device:weight pair
func (*WeightDevice) String ¶
func (w *WeightDevice) String() string