docker

package
v0.0.0-...-21d6f6e Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContainerFsm = containerFsm{
		Created:  []State{Starting, Running, Failed, Stopped, Removed},
		Starting: []State{Running, Failed, Stopping},
		Running:  []State{Running, Failed, Stopping, Stopped},
		Stopping: []State{Failed, Stopped},
		Stopped:  []State{Removed},
		Failed:   []State{Removed},
	}
)

Functions

func GetEth0Ip

func GetEth0Ip() ([]string, error)

Note that this depends on the context in which it is run. If this is run from the host (outside container), then it will return the address at eth0, but if it's run from inside a container, the eth0 interface is actually the docker0 interface on the host.

func ImageEquals

func ImageEquals(a, b interface{}) bool

func ImageLessBySemanticVersion

func ImageLessBySemanticVersion(a, b interface{}) bool

func ParseDockerImage

func ParseDockerImage(dockerImage string) (repo, tag string, err error)

Types

type Action

type Action int
const (
	Create Action = iota
	Start
	Stop
	Remove
	Die
)

type AuthIdentity

type AuthIdentity struct {
	docker.AuthConfiguration
}

type Container

type Container struct {
	Id      string `json:"id"`
	Ip      string `json:"ip"`
	Image   string `json:"image"`
	ImageId string `json:"image_id"`

	Name    string `json:"name"`
	Command string `json:"command"`
	Ports   []Port `json:"ports"`
	Network docker.NetworkSettings

	DockerData *docker.Container `json:"docker_data"`
	// contains filtered or unexported fields
}

func (*Container) GetComparable

func (c *Container) GetComparable() string

func (*Container) Inspect

func (c *Container) Inspect() error

type ContainerCollection

type ContainerCollection struct {
	Image   string
	FsmById map[string]*fsm.Fsm
}

For all instances of a same container image version.

func NewContainerCollection

func NewContainerCollection(image string) *ContainerCollection

func (*ContainerCollection) Add

func (cg *ContainerCollection) Add(c *Container) *fsm.Fsm

func (*ContainerCollection) Empty

func (cg *ContainerCollection) Empty() bool

func (ContainerCollection) GetKey

func (c ContainerCollection) GetKey() interface{}

func (ContainerCollection) Instances

func (c ContainerCollection) Instances() []*fsm.Fsm

func (*ContainerCollection) Remove

func (cg *ContainerCollection) Remove(c *Container)

func (ContainerCollection) String

func (c ContainerCollection) String() string

type ContainerControl

type ContainerControl struct {
	*docker.Config

	// If false, the container starts up in daemon mode (as a service) - default
	RunOnce       bool               `json:"run_once,omitempty"`
	HostConfig    *docker.HostConfig `json:"host_config"`
	ContainerName string             `json:"name,omitempty"`
}

type ContainerState

type ContainerState int
const (
	Created ContainerState = iota
	Starting
	Running  // ready running
	Stopping // initiated stop
	Stopped  // stopped
	Failed   // uninitiated / unexpected stop
	Removed  // removed
)

func (ContainerState) Equals

func (this ContainerState) Equals(that State) bool

func (ContainerState) String

func (this ContainerState) String() string

type Docker

type Docker struct {
	Endpoint string

	Cert string
	Key  string
	Ca   string

	ContainerCreated func(*Container)
	ContainerStarted func(*Container)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string) (c *Docker, err error)

func NewTLSClient

func NewTLSClient(endpoint string, cert, key, ca string) (c *Docker, err error)

Endpoint and file paths

func (*Docker) FindContainers

func (c *Docker) FindContainers(filter map[string][]string) ([]*Container, error)

func (*Docker) FindContainersByName

func (c *Docker) FindContainersByName(name string) ([]*Container, error)

func (*Docker) ListContainers

func (c *Docker) ListContainers() ([]*Container, error)

func (*Docker) PullImage

func (c *Docker) PullImage(auth *AuthIdentity, image *Image) (<-chan error, error)

func (*Docker) RemoveContainer

func (c *Docker) RemoveContainer(auth *AuthIdentity, id string, removeVolumes, force bool) error

func (*Docker) RemoveImage

func (c *Docker) RemoveImage(image string, force, prune bool) error

func (*Docker) StartContainer

func (c *Docker) StartContainer(auth *AuthIdentity, ct *ContainerControl) (*Container, error)

func (*Docker) StopContainer

func (c *Docker) StopContainer(auth *AuthIdentity, id string, timeout time.Duration) error

func (*Docker) WatchContainer

func (c *Docker) WatchContainer(notify func(Action, *Container)) (chan<- bool, error)

func (*Docker) WatchContainerMatching

func (c *Docker) WatchContainerMatching(accept func(Action, *Container) bool, notify func(Action, *Container)) (chan<- bool, error)

type Image

type Image struct {
	Registry   string `json:"registry"`
	Repository string `json:"repository"`
	Tag        string `json:"tag"`
}

func ParseImageUrl

func ParseImageUrl(url string) Image

func (Image) ImageString

func (this Image) ImageString() string

func (Image) Url

func (this Image) Url() string

type Port

type Port struct {
	ContainerPort int64  `json:"container_port"`
	HostPort      int64  `json:"host_port"`
	Type          string `json:"protocol"`
	AcceptIP      string `json:"accepts_ip"`
}

Jump to

Keyboard shortcuts

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