docker

package
v0.0.0-...-88aa921 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

Strings identifying the Docker lifecycle events.

View Source
const (
	Wildcard = "*"
)

Variables

View Source
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")
	ErrNoSuchImage     = errors.New("docker: no such image")
)

Container subsystem error types

View Source
var DEFAULT_REGISTRY = "localhost:5000"

Functions

func CancelOnContainerCreated

func CancelOnContainerCreated(id string) error

CancelOnContainerCreated cancels any OnContainerCreated action associated with the specified id - docker.Wildcard is the only id that really makes sense.

func ImageHistory

func ImageHistory(uuid string) ([]*dockerclient.Image, error)

func ImportImage

func ImportImage(repotag, filename string) error

ImportImage creates a new image in the local repository from a file system archive.

func InspectImage

func InspectImage(uuid string) (*dockerclient.Image, error)

func Logs

func Logs(dockerID string, args []string) error

Logs calls docker logs for a running service container

func OnContainerCreated

func OnContainerCreated(id string, action ContainerActionFunc) error

OnContainerCreated associates a containter action with the specified container. The action will be triggered when that container is created; since we can't know before it's created what a containers id will be the only really useful id is docker.Wildcard which will cause the action to be triggered for every container docker creates.

func PullImage

func PullImage(repotag string) error

func PushImage

func PushImage(repotag string) error

PushImage pushes an image by repotag to local registry, e.g., zenoss/devimg, from the local docker repository

func ServiceUse

func ServiceUse(serviceID string, imageName string, registry string, noOp bool) (string, error)

ServiceUse will tag a new image (imageName) in a given registry for a given tenant to latest, making sure to push changes to the registry

func SetDockerClientGetter

func SetDockerClientGetter(getterOverride DockerClientGetter)

Used by tests that need to inject a mock or stub implementation of Client

func SetUseRegistry

func SetUseRegistry(ur bool)

SetUseRegistry sets the value of useRegistry

func UseRegistry

func UseRegistry() bool

UseRegistry returns the value of useRegistry

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 (*Client) ExportContainer

func (c *Client) ExportContainer(opts dockerclient.ExportContainerOptions) 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 (*Client) ListImages

func (c *Client) ListImages(all bool) ([]dockerclient.APIImages, error)

func (*Client) MonitorEvents

func (c *Client) MonitorEvents() (dockerclient.EventMonitor, error)

func (*Client) PullImage

func (*Client) PushImage

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(opts dockerclient.RemoveContainerOptions) error

func (*Client) RemoveImage

func (c *Client) RemoveImage(name string) error

func (*Client) RestartContainer

func (c *Client) RestartContainer(id string, timeout uint) error

func (*Client) StartContainer

func (c *Client) StartContainer(id string, hostConfig *dockerclient.HostConfig) error

func (*Client) StopContainer

func (c *Client) StopContainer(id string, timeout uint) error

func (*Client) TagImage

func (c *Client) TagImage(name string, opts dockerclient.TagImageOptions) error

func (*Client) WaitContainer

func (c *Client) WaitContainer(id string) (int, 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

	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(all bool) ([]dockerclient.APIImages, error)

	MonitorEvents() (dockerclient.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)
}

An interface respresentation of dockerclient.Client

func NewClient

func NewClient(dockerRegistry string) (ClientInterface, error)

type Container

type Container struct {
	*dockerclient.Container
	dockerclient.HostConfig
}

Container represents a Docker container.

func Containers

func Containers() ([]*Container, error)

Containers retrieves a list of all the Docker containers.

func FindContainer

func FindContainer(id string) (*Container, error)

FindContainer looks up a container using its id or name.

func NewContainer

func NewContainer(cd *ContainerDefinition, 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

func (c *Container) CancelOnEvent(event string) error

CancelOnEvent cancels the action associated with the specified event.

func (*Container) Commit

func (c *Container) Commit(iidstr string) (*Image, error)

Commit creates a new Image from the containers changes.

func (*Container) Delete

func (c *Container) Delete(volumes bool) error

Delete removes the container.

func (*Container) Export

func (c *Container) Export(outfile *os.File) error

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) IsRunning

func (c *Container) IsRunning() bool

IsRunning inspects the container and returns true if it is running

func (*Container) Kill

func (c *Container) Kill() error

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) Restart

func (c *Container) Restart(timeout time.Duration) error

Restart stops and then restarts a container.

func (*Container) Start

func (c *Container) Start(timeout time.Duration) error

Start uses the information provided in the container definition cd to start a new Docker container. If a container can't be started before the timeout expires an error is returned.

func (*Container) Stop

func (c *Container) Stop(timeout time.Duration) error

Stop stops the container specified by the id. If the container can't be stopped before the timeout expires an error is returned.

func (*Container) Wait

func (c *Container) Wait(timeout time.Duration) (int, error)

Wait blocks until the container stops or the timeout expires and then returns its exit code.

type ContainerActionFunc

type ContainerActionFunc func(id string)

ContainerActionFunc instances are used to handle container action notifications.

type ContainerDefinition

type ContainerDefinition struct {
	dockerclient.CreateContainerOptions
	dockerclient.HostConfig
}

ContainerDefinition records all the information necessary to create a Docker container.

type DockerClientGetter

type DockerClientGetter func() (ClientInterface, error)

The function used to get an instance of ClientInterface

type Image

type Image struct {
	UUID string
	ID   commons.ImageID
}

Image represents a Docker image

func FindImage

func FindImage(repotag string, pull bool) (*Image, error)

FindImage looks up an image by repotag, e.g., zenoss/devimg, from the local repository TODO: add a FindImageByFilter that returns collections of images

func Images

func Images() ([]*Image, error)

Images returns a list of all the named images in the local repository

func TagImage

func TagImage(img *Image, tag string) (*Image, error)

func (*Image) Delete

func (img *Image) Delete() error

Delete remove the image from the local repository

func (*Image) History

func (img *Image) History() ([]*dockerclient.Image, error)

func (*Image) Inspect

func (img *Image) Inspect() (*dockerclient.Image, error)

func (*Image) Tag

func (img *Image) Tag(tag string) (*Image, error)

Tag tags an image in the local repository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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