Documentation ¶
Index ¶
- Constants
- Variables
- func ImageHistory(uuid string) ([]*dockerclient.Image, error)
- func ImportImage(repotag, filename string) error
- func InspectImage(uuid string) (*dockerclient.Image, error)
- func IsImageNotFound(err error) bool
- func LoadImages(filename string) error
- func Logs(dockerID string, args []string) error
- func PullImage(repotag string) error
- func PushImage(repotag string) error
- func RunTTL(cancel <-chan interface{}, min, max time.Duration)
- func SaveImages(outfile *os.File, repotags ...string) error
- func SetDockerClientGetter(getterOverride DockerClientGetter)
- func StartKernel()
- type Client
- func (c *Client) CommitContainer(opts dockerclient.CommitContainerOptions) (*dockerclient.Image, error)
- func (c *Client) CreateContainer(opts dockerclient.CreateContainerOptions) (*dockerclient.Container, error)
- func (c *Client) ExportContainer(opts dockerclient.ExportContainerOptions) error
- func (c *Client) ExportImages(opts dockerclient.ExportImagesOptions) error
- func (c *Client) ImportImage(opts dockerclient.ImportImageOptions) error
- func (c *Client) InspectContainer(id string) (*dockerclient.Container, error)
- func (c *Client) InspectImage(name string) (*dockerclient.Image, error)
- func (c *Client) KillContainer(opts dockerclient.KillContainerOptions) error
- func (c *Client) ListContainers(opts dockerclient.ListContainersOptions) ([]dockerclient.APIContainers, error)
- func (c *Client) ListImages(opts dockerclient.ListImagesOptions) ([]dockerclient.APIImages, error)
- func (c *Client) LoadImage(opts dockerclient.LoadImageOptions) error
- func (c *Client) MonitorEvents() (EventMonitor, error)
- func (c *Client) PullImage(opts dockerclient.PullImageOptions, auth dockerclient.AuthConfiguration) error
- func (c *Client) PushImage(opts dockerclient.PushImageOptions, auth dockerclient.AuthConfiguration) error
- func (c *Client) RemoveContainer(opts dockerclient.RemoveContainerOptions) error
- func (c *Client) RemoveImage(name string) error
- func (c *Client) RestartContainer(id string, timeout uint) error
- func (c *Client) StartContainer(id string, hostConfig *dockerclient.HostConfig) error
- func (c *Client) StopContainer(id string, timeout uint) error
- func (c *Client) TagImage(name string, opts dockerclient.TagImageOptions) error
- func (c *Client) Version() (*dockerclient.Env, error)
- func (c *Client) WaitContainer(id string) (int, error)
- type ClientInterface
- type Container
- func (c *Container) CancelOnEvent(event string) error
- func (c *Container) Commit(iidstr string, push bool) (*Image, error)
- func (c *Container) Delete(volumes bool) error
- func (c *Container) Export(outfile *os.File) error
- func (c *Container) Inspect() (*dockerclient.Container, error)
- func (c *Container) IsRunning() bool
- func (c *Container) Kill() error
- func (c *Container) OnEvent(event string, action ContainerActionFunc) error
- func (c *Container) Restart(timeout time.Duration) error
- func (c *Container) Start() error
- func (c *Container) Stop(timeout time.Duration) error
- func (c *Container) Wait(timeout time.Duration) (int, error)
- type ContainerActionFunc
- type DockerClientGetter
- type DockerRegistryInterface
- type DockerTTL
- type EventMonitor
- type HandlerFunc
- type Image
- type ImageNotFound
- type Subscription
Constants ¶
const ( Create = "create" Delete = "delete" Destroy = "destroy" Die = "die" Export = "export" Kill = "kill" Restart = "restart" Start = "start" Stop = "stop" Untag = "untag" )
Selectors for the various Docker lifecycle events.
const AllThingsDocker = "*"
AllThingsDocker is a wildcard used to express interest in the Docker lifecycle event streams of all containers and images.
const DockerLatest = "latest"
const (
Wildcard = "*"
)
Variables ¶
var ( ErrAlreadyStarted = errors.New("docker: container already started") ErrRequestTimeout = errors.New("docker: request timed out") ErrKernelShutdown = errors.New("docker: kernel shutdown") ErrNoSuchContainer = errors.New("docker: no such container") )
Container subsystem error types
Functions ¶
func ImageHistory ¶
func ImageHistory(uuid string) ([]*dockerclient.Image, error)
func ImportImage ¶
ImportImage creates a new image in the local repository from a file system archive.
func InspectImage ¶
func InspectImage(uuid string) (*dockerclient.Image, error)
func IsImageNotFound ¶
IsImageNotFound parses an err to determine whether the image is not found
func LoadImages ¶
func PushImage ¶
PushImage pushes an image by repotag to local registry, e.g., zenoss/devimg, from the local docker repository
func SetDockerClientGetter ¶
func SetDockerClientGetter(getterOverride DockerClientGetter)
Used by tests that need to inject a mock or stub implementation of Client
func StartKernel ¶
func StartKernel()
StartKernel starts up the kernel loop that is responsible for handling all the API calls in a goroutine.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
This Client/ClientInterface is a shim for dockerclient.Client. All references to dockerclient.Client shoudl be isolated in Client/ClientInterface
func (*Client) CommitContainer ¶
func (c *Client) CommitContainer(opts dockerclient.CommitContainerOptions) (*dockerclient.Image, error)
func (*Client) CreateContainer ¶
func (c *Client) CreateContainer(opts dockerclient.CreateContainerOptions) (*dockerclient.Container, error)
func (*Client) ExportContainer ¶
func (c *Client) ExportContainer(opts dockerclient.ExportContainerOptions) error
func (*Client) ExportImages ¶
func (c *Client) ExportImages(opts dockerclient.ExportImagesOptions) error
func (*Client) ImportImage ¶
func (c *Client) ImportImage(opts dockerclient.ImportImageOptions) error
func (*Client) InspectContainer ¶
func (c *Client) InspectContainer(id string) (*dockerclient.Container, error)
func (*Client) InspectImage ¶
func (c *Client) InspectImage(name string) (*dockerclient.Image, error)
func (*Client) KillContainer ¶
func (c *Client) KillContainer(opts dockerclient.KillContainerOptions) error
func (*Client) ListContainers ¶
func (c *Client) ListContainers(opts dockerclient.ListContainersOptions) ([]dockerclient.APIContainers, error)
func (*Client) ListImages ¶
func (c *Client) ListImages(opts dockerclient.ListImagesOptions) ([]dockerclient.APIImages, error)
func (*Client) LoadImage ¶
func (c *Client) LoadImage(opts dockerclient.LoadImageOptions) error
func (*Client) MonitorEvents ¶
func (c *Client) MonitorEvents() (EventMonitor, error)
func (*Client) PullImage ¶
func (c *Client) PullImage(opts dockerclient.PullImageOptions, auth dockerclient.AuthConfiguration) error
func (*Client) PushImage ¶
func (c *Client) PushImage(opts dockerclient.PushImageOptions, auth dockerclient.AuthConfiguration) error
func (*Client) RemoveContainer ¶
func (c *Client) RemoveContainer(opts dockerclient.RemoveContainerOptions) error
func (*Client) RemoveImage ¶
func (*Client) StartContainer ¶
func (c *Client) StartContainer(id string, hostConfig *dockerclient.HostConfig) error
func (*Client) TagImage ¶
func (c *Client) TagImage(name string, opts dockerclient.TagImageOptions) error
type ClientInterface ¶
type ClientInterface interface { CommitContainer(opts dockerclient.CommitContainerOptions) (*dockerclient.Image, error) CreateContainer(opts dockerclient.CreateContainerOptions) (*dockerclient.Container, error) ExportContainer(opts dockerclient.ExportContainerOptions) error ImportImage(opts dockerclient.ImportImageOptions) error ExportImages(opts dockerclient.ExportImagesOptions) error LoadImage(opts dockerclient.LoadImageOptions) error InspectContainer(id string) (*dockerclient.Container, error) InspectImage(name string) (*dockerclient.Image, error) KillContainer(opts dockerclient.KillContainerOptions) error ListContainers(opts dockerclient.ListContainersOptions) ([]dockerclient.APIContainers, error) ListImages(opts dockerclient.ListImagesOptions) ([]dockerclient.APIImages, error) MonitorEvents() (EventMonitor, error) PullImage(opts dockerclient.PullImageOptions, auth dockerclient.AuthConfiguration) error PushImage(opts dockerclient.PushImageOptions, auth dockerclient.AuthConfiguration) error RemoveContainer(opts dockerclient.RemoveContainerOptions) error RemoveImage(name string) error RestartContainer(id string, timeout uint) error StartContainer(id string, hostConfig *dockerclient.HostConfig) error StopContainer(id string, timeout uint) error TagImage(name string, opts dockerclient.TagImageOptions) error WaitContainer(id string) (int, error) Version() (*dockerclient.Env, error) }
An interface respresentation of dockerclient.Client
func NewClient ¶
func NewClient() (ClientInterface, error)
type Container ¶
type Container struct {
*dockerclient.Container
}
Container represents a Docker container.
func Containers ¶
Containers retrieves a list of all the Docker containers.
func FindContainer ¶
FindContainer looks up a container using its id or name.
func NewContainer ¶
func NewContainer(cd *dockerclient.CreateContainerOptions, start bool, timeout time.Duration, oncreate ContainerActionFunc, onstart ContainerActionFunc) (*Container, error)
NewContainer creates a new container and returns its id. The supplied create action, if any, will be executed on successful creation of the container. If a start action is specified it will be executed after the container has been started. Note, if the start parameter is false the container won't be started and the start action will not be executed.
func (*Container) CancelOnEvent ¶
CancelOnEvent cancels the action associated with the specified event.
func (*Container) Export ¶
Export writes the contents of the container's filesystem as a tar archive to outfile.
func (*Container) Inspect ¶
func (c *Container) Inspect() (*dockerclient.Container, error)
Inspect returns information about the container specified by id.
func (*Container) Kill ¶
Kill sends a SIGKILL signal to the container. If the container is not started no action is taken.
func (*Container) OnEvent ¶
func (c *Container) OnEvent(event string, action ContainerActionFunc) error
OnEvent adds an action for the specified event.
func (*Container) Start ¶
Start uses the information provided in the container definition cd to start a new Docker container. If a container can't be completely started an error is returned. The bool returned specifies whether the caller should expect a events (Start, Die, ...) from the Docker subsystem.
type ContainerActionFunc ¶
type ContainerActionFunc func(id string)
ContainerActionFunc instances are used to handle container action notifications.
type DockerClientGetter ¶
type DockerClientGetter func() (ClientInterface, error)
The function used to get an instance of ClientInterface
type DockerRegistryInterface ¶
type DockerRegistryInterface interface { FindImage(repotag string, pull bool) (*Image, error) PullImage(repotag string) error PushImage(repotag string) error }
The DockerRegistryInterface is the API for interactions with the docker registry FIXME: Add other methods as time permits. The initial version was only a partial implementation in the interests of time.
type EventMonitor ¶
type EventMonitor interface { // IsActive reports whether or not an EventMonitor is active, i.e., listening for Docker events. IsActive() bool // Subscribe returns a subscription to which handlers for the various Docker lifecycle events // for the container or image specified by ID (or all containers and images if AllThingsDocker // is passed) may be added. Subscribe(ID string) (*Subscription, error) // Close causes the EventMonitor to stop listening for Docker lifecycle events. Close() error }
EventMonitor implementations may be used to subscribe to Docker lifecycle events. This package provides such an implementation. Instances of it may be retreived via the client.EventMonitor() method.
type HandlerFunc ¶
type HandlerFunc func(e *dockerclient.APIEvents) error
A HandlerFunc is used to receive Docker lifecycle events.
type Image ¶
Image represents a Docker image
func FindImage ¶
FindImage looks up an image by repotag, e.g., zenoss/devimg, from the local repository TODO: add a FindImageByFilter that returns collections of images
type ImageNotFound ¶
ImageNotFound is a an error type when an image is not found
type Subscription ¶
type Subscription struct { ID string // contains filtered or unexported fields }
Subscription represents a subscription to a particular container or image's Docker lifecycle event stream. The AllThingsDocker ID can be used to subscribe to all container and image event streams.
func (*Subscription) Cancel ¶
func (s *Subscription) Cancel() error
Cancel causes the Subscription to stop receiving and dispatching Docker container and image lifecycle events.
func (*Subscription) Handle ¶
func (s *Subscription) Handle(es string, h HandlerFunc) error
Handle associates a HandlerFunc h with a the Docker container or image lifecycle event specified by es. Any HandlerFunc previously associated with es is replaced.