Documentation ¶
Index ¶
- Constants
- type Cluster
- type Container
- type ContainerConfig
- type Containers
- type DriverOpts
- type Engine
- func (e *Engine) AddContainer(container *Container) error
- func (e *Engine) BuildImage(buildImage *dockerclient.BuildImage) (io.ReadCloser, error)
- func (e *Engine) Connect(config *tls.Config) error
- func (e *Engine) ConnectWithClient(client dockerclient.Client) error
- func (e *Engine) Containers() Containers
- func (e *Engine) Create(config *ContainerConfig, name string, pullImage bool) (*Container, error)
- func (e *Engine) Disconnect()
- func (e *Engine) Image(IDOrName string) *Image
- func (e *Engine) Images(all bool) []*Image
- func (e *Engine) Import(source string, repository string, tag string, imageReader io.Reader) error
- func (e *Engine) IsHealthy() bool
- func (e *Engine) Load(reader io.Reader) error
- func (e *Engine) Pull(image string, authConfig *dockerclient.AuthConfig) error
- func (e *Engine) RefreshContainers(full bool) error
- func (e *Engine) RefreshImages() error
- func (e *Engine) RefreshVolumes() error
- func (e *Engine) RegisterEventHandler(h EventHandler) error
- func (e *Engine) RemoveContainer(container *Container, force bool) error
- func (e *Engine) RemoveImage(image *Image, name string, force bool) ([]*dockerclient.ImageDelete, error)
- func (e *Engine) RenameContainer(container *Container, newName string) error
- func (e *Engine) String() string
- func (e *Engine) TagImage(IDOrName string, repo string, tag string, force bool) error
- func (e *Engine) TotalCpus() int64
- func (e *Engine) TotalMemory() int64
- func (e *Engine) UsedCpus() int64
- func (e *Engine) UsedMemory() int64
- func (e *Engine) Volumes() []*Volume
- type EngineSorter
- type Event
- type EventHandler
- type Image
- type Volume
Constants ¶
const SwarmLabelNamespace = "com.docker.swarm"
SwarmLabelNamespace defines the key prefix in all custom labels
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster interface { // Create a container CreateContainer(config *ContainerConfig, name string) (*Container, error) // Remove a container RemoveContainer(container *Container, force bool) error // Return all images Images(all bool) []*Image // Return one image matching `IDOrName` Image(IDOrName string) *Image // Remove images from the cluster RemoveImages(name string, force bool) ([]*dockerclient.ImageDelete, error) // Return all containers Containers() Containers // Return container the matching `IDOrName` // TODO: remove this method from the interface as we can use // cluster.Containers().Get(IDOrName) Container(IDOrName string) *Container // Return all volumes Volumes() []*Volume // Return one volume from the cluster Volume(name string) *Volume // Pull images // `callback` can be called multiple time // `where` is where it is being pulled // `status` is the current status, like "", "in progress" or "downloaded Pull(name string, authConfig *dockerclient.AuthConfig, callback func(where, status string, err error)) // Import image // `callback` can be called multiple time // `where` is where it is being imported // `status` is the current status, like "", "in progress" or "imported" Import(source string, repository string, tag string, imageReader io.Reader, callback func(where, status string)) // Load images // `callback` can be called multiple time // `what` is what is being loaded // `status` is the current status, like "", "in progress" or "loaded" Load(imageReader io.Reader, callback func(what, status string)) // Return some info about the cluster, like nb or containers / images // It is pretty open, so the implementation decides what to return. Info() [][]string // Return the total memory of the cluster TotalMemory() int64 // Return the number of CPUs in the cluster TotalCpus() int64 // Register an event handler for cluster-wide events. RegisterEventHandler(h EventHandler) error // FIXME: remove this method // Return a random engine RANDOMENGINE() (*Engine, error) // RenameContainer rename a container RenameContainer(container *Container, newName string) error // BuildImage build an image BuildImage(*dockerclient.BuildImage, io.Writer) error // TagImage tag an image TagImage(IDOrName string, repo string, tag string, force bool) error }
Cluster is exported
type Container ¶
type Container struct { dockerclient.Container Config *ContainerConfig Info dockerclient.ContainerInfo Engine *Engine }
Container is exported
type ContainerConfig ¶
type ContainerConfig struct {
dockerclient.ContainerConfig
}
ContainerConfig is exported TODO store affinities and constraints in their own fields
func BuildContainerConfig ¶
func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig
BuildContainerConfig creates a cluster.ContainerConfig from a dockerclient.ContainerConfig
func (*ContainerConfig) AddAffinity ¶
func (c *ContainerConfig) AddAffinity(affinity string) error
AddAffinity to config
func (*ContainerConfig) Affinities ¶
func (c *ContainerConfig) Affinities() []string
Affinities returns all the affinities from the ContainerConfig
func (*ContainerConfig) Constraints ¶
func (c *ContainerConfig) Constraints() []string
Constraints returns all the constraints from the ContainerConfig
func (*ContainerConfig) SetSwarmID ¶
func (c *ContainerConfig) SetSwarmID(id string)
SetSwarmID sets or overrides the Swarm ID in the Config.
func (*ContainerConfig) SwarmID ¶
func (c *ContainerConfig) SwarmID() string
SwarmID extracts the Swarm ID from the Config. May return an empty string if not set.
type Containers ¶
type Containers []*Container
Containers represents a list a containers
func (Containers) Get ¶
func (containers Containers) Get(IDOrName string) *Container
Get returns a container using it's ID or Name
type DriverOpts ¶
type DriverOpts []string
DriverOpts are key=values options
func (DriverOpts) Float ¶
func (do DriverOpts) Float(key, env string) (float64, bool)
Float returns a float64 from the driver options
func (DriverOpts) IP ¶
func (do DriverOpts) IP(key, env string) (net.IP, bool)
IP returns an IP address from the driver options
func (DriverOpts) Int ¶
func (do DriverOpts) Int(key, env string) (int64, bool)
Int returns an int64 from the driver options
type Engine ¶
type Engine struct { sync.RWMutex ID string IP string Addr string Name string Cpus int64 Memory int64 Labels map[string]string // contains filtered or unexported fields }
Engine represents a docker engine
func (*Engine) AddContainer ¶
AddContainer inject a container into the internal state.
func (*Engine) BuildImage ¶
func (e *Engine) BuildImage(buildImage *dockerclient.BuildImage) (io.ReadCloser, error)
BuildImage build an image
func (*Engine) Connect ¶
Connect will initialize a connection to the Docker daemon running on the host, gather machine specs (memory, cpu, ...) and monitor state changes.
func (*Engine) ConnectWithClient ¶
func (e *Engine) ConnectWithClient(client dockerclient.Client) error
ConnectWithClient is exported
func (*Engine) Containers ¶
func (e *Engine) Containers() Containers
Containers returns all the containers in the engine.
func (*Engine) Disconnect ¶
func (e *Engine) Disconnect()
Disconnect will stop all monitoring of the engine. The Engine object cannot be further used without reconnecting it first.
func (*Engine) Pull ¶
func (e *Engine) Pull(image string, authConfig *dockerclient.AuthConfig) error
Pull an image on the engine
func (*Engine) RefreshContainers ¶
RefreshContainers will refresh the list and status of containers running on the engine. If `full` is true, each container will be inspected. FIXME: unexport this method after mesos scheduler stops using it directly
func (*Engine) RefreshImages ¶
RefreshImages refreshes the list of images on the engine.
func (*Engine) RefreshVolumes ¶
RefreshVolumes refreshes the list of volumes on the engine.
func (*Engine) RegisterEventHandler ¶
func (e *Engine) RegisterEventHandler(h EventHandler) error
RegisterEventHandler registers an event handler.
func (*Engine) RemoveContainer ¶
RemoveContainer a container from the engine.
func (*Engine) RemoveImage ¶
func (e *Engine) RemoveImage(image *Image, name string, force bool) ([]*dockerclient.ImageDelete, error)
RemoveImage deletes an image from the engine.
func (*Engine) RenameContainer ¶
RenameContainer rename a container
func (*Engine) TotalMemory ¶
TotalMemory returns the total memory + overcommit
func (*Engine) UsedMemory ¶
UsedMemory returns the sum of memory reserved by containers.
type EngineSorter ¶
type EngineSorter []*Engine
EngineSorter implements the Sort interface to sort Cluster.Engine. It is not guaranteed to be a stable sort.
func (EngineSorter) Len ¶
func (s EngineSorter) Len() int
Len returns the number of engines to be sorted.
func (EngineSorter) Less ¶
func (s EngineSorter) Less(i, j int) bool
Less reports whether the engine with index i should sort before the engine with index j. Engines are sorted chronologically by name.
func (EngineSorter) Swap ¶
func (s EngineSorter) Swap(i, j int)
Swap exchanges the engine elements with indices i and j.