Documentation
¶
Index ¶
- Variables
- type BuildOptions
- type ExecOptions
- type Network
- type Pool
- func (d *Pool) BuildAndRun(name, dockerfilePath string, env []string) (*Resource, error)
- func (d *Pool) BuildAndRunWithBuildOptions(buildOpts *BuildOptions, runOpts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)
- func (d *Pool) BuildAndRunWithOptions(dockerfilePath string, opts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)
- func (d *Pool) ContainerByName(containerName string) (*Resource, bool)
- func (d *Pool) CreateNetwork(name string, opts ...func(config *dc.CreateNetworkOptions)) (*Network, error)
- func (d *Pool) CurrentContainer() (*Resource, error)
- func (d *Pool) Purge(r *Resource) error
- func (d *Pool) RemoveContainerByName(containerName string) error
- func (d *Pool) RemoveNetwork(network *Network) error
- func (d *Pool) Retry(op func() error) error
- func (d *Pool) Run(repository, tag string, env []string) (*Resource, error)
- func (d *Pool) RunWithOptions(opts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)
- type Resource
- func (r *Resource) Close() error
- func (r *Resource) ConnectToNetwork(network *Network) error
- func (r *Resource) DisconnectFromNetwork(network *Network) error
- func (r *Resource) Exec(cmd []string, opts ExecOptions) (exitCode int, err error)
- func (r *Resource) Expire(seconds uint) error
- func (r *Resource) GetBoundIP(id string) string
- func (r *Resource) GetHostPort(portID string) string
- func (r *Resource) GetIPInNetwork(network *Network) string
- func (r *Resource) GetPort(id string) string
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotInContainer = errors.New("not running in container")
)
Functions ¶
This section is empty.
Types ¶
type BuildOptions ¶
BuildOptions is used to pass in optional parameters when building a container
type ExecOptions ¶
type ExecOptions struct { // Command environment, optional. Env []string // StdIn will be attached as command stdin if provided. StdIn io.Reader // StdOut will be attached as command stdout if provided. StdOut io.Writer // StdErr will be attached as command stdout if provided. StdErr io.Writer // Allocate TTY for command or not. TTY bool }
type Pool ¶
Pool represents a connection to the docker API and is used to create and remove docker images.
func NewPool ¶
NewPool creates a new pool. You can pass an empty string to use the default, which is taken from the environment variable DOCKER_HOST and DOCKER_URL, or from docker-machine if the environment variable DOCKER_MACHINE_NAME is set, or if neither is defined a sensible default for the operating system you are on. TLS pools are automatically configured if the DOCKER_CERT_PATH environment variable exists.
func NewTLSPool ¶
NewTLSPool creates a new pool given an endpoint and the certificate path. This is required for endpoints that require TLS communication.
func (*Pool) BuildAndRun ¶
BuildAndRun builds and starts a docker container
func (*Pool) BuildAndRunWithBuildOptions ¶
func (d *Pool) BuildAndRunWithBuildOptions(buildOpts *BuildOptions, runOpts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)
BuildAndRunWithBuildOptions builds and starts a docker container. Optional modifier functions can be passed in order to change the hostconfig values not covered in RunOptions
func (*Pool) BuildAndRunWithOptions ¶
func (d *Pool) BuildAndRunWithOptions(dockerfilePath string, opts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)
BuildAndRunWithOptions builds and starts a docker container. Optional modifier functions can be passed in order to change the hostconfig values not covered in RunOptions
func (*Pool) ContainerByName ¶
ContainerByName finds a container with the given name and returns it if present
func (*Pool) CreateNetwork ¶
func (d *Pool) CreateNetwork(name string, opts ...func(config *dc.CreateNetworkOptions)) (*Network, error)
CreateNetwork creates docker network. It's useful for linking multiple containers.
func (*Pool) CurrentContainer ¶
CurrentContainer returns current container descriptor if this function called within running container. It returns ErrNotInContainer as error if this function running not in container.
func (*Pool) RemoveContainerByName ¶
RemoveContainerByName find a container with the given name and removes it if present
func (*Pool) RemoveNetwork ¶
RemoveNetwork disconnects containers and removes provided network.
func (*Pool) Retry ¶
Retry is an exponential backoff retry helper. You can use it to wait for e.g. mysql to boot up.
func (*Pool) Run ¶
Run starts a docker container.
pool.Run("mysql", "5.3", []string{"FOO=BAR", "BAR=BAZ"})
func (*Pool) RunWithOptions ¶
func (d *Pool) RunWithOptions(opts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)
RunWithOptions starts a docker container. Optional modifier functions can be passed in order to change the hostconfig values not covered in RunOptions
pool.RunWithOptions(&RunOptions{Repository: "mongo", Cmd: []string{"mongod", "--smallfiles"}}) pool.RunWithOptions(&RunOptions{Repository: "mongo", Cmd: []string{"mongod", "--smallfiles"}}, func(hostConfig *dc.HostConfig) { hostConfig.ShmSize = shmemsize })
type Resource ¶
Resource represents a docker container.
func (*Resource) Close ¶
Close removes a container and linked volumes from docker by calling pool.Purge.
func (*Resource) ConnectToNetwork ¶
ConnectToNetwork connects container to network.
func (*Resource) DisconnectFromNetwork ¶
DisconnectFromNetwork disconnects container from network.
func (*Resource) Exec ¶
func (r *Resource) Exec(cmd []string, opts ExecOptions) (exitCode int, err error)
Exec executes command within container.
func (*Resource) Expire ¶
Expire sets a resource's associated container to terminate after a period has passed
func (*Resource) GetBoundIP ¶
GetBoundIP returns a resource's published IP address.
func (*Resource) GetHostPort ¶
GetHostPort returns a resource's published port with an address.
func (*Resource) GetIPInNetwork ¶
GetIPInNetwork returns container IP address in network.
type RunOptions ¶
type RunOptions struct { Hostname string Name string Repository string Tag string Env []string Entrypoint []string Cmd []string Mounts []string Links []string ExposedPorts []string ExtraHosts []string CapAdd []string SecurityOpt []string DNS []string WorkingDir string NetworkID string Networks []*Network // optional networks to join Labels map[string]string Auth dc.AuthConfiguration PortBindings map[dc.Port][]dc.PortBinding Privileged bool User string Tty bool }
RunOptions is used to pass in optional parameters when running a container.
Directories
¶
Path | Synopsis |
---|---|
Package docker provides a client for the Docker remote API.
|
Package docker provides a client for the Docker remote API. |
pkg/pools
Package pools provides a collection of pools which provide various data types with buffers.
|
Package pools provides a collection of pools which provide various data types with buffers. |
types
Package types is used for API stability in the types and response to the consumers of the API stats endpoint.
|
Package types is used for API stability in the types and response to the consumers of the API stats endpoint. |
types/filters
Package filters provides tools for encoding a mapping of keys to a set of multiple values.
|
Package filters provides tools for encoding a mapping of keys to a set of multiple values. |
types/versions/v1p19
Package v1p19 provides specific API types for the API version 1, patch 19.
|
Package v1p19 provides specific API types for the API version 1, patch 19. |
types/versions/v1p20
Package v1p20 provides specific API types for the API version 1, patch 20.
|
Package v1p20 provides specific API types for the API version 1, patch 20. |