Documentation
¶
Overview ¶
Package docker contains utils and helpers for commonly used Docker idioms.
Index ¶
- func BuildImage(ctx context.Context, ow *rpc.OutputWriter, client *client.Client, ...) error
- func CheckBridgeNetwork(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, name string) ([]types.NetworkResource, error)
- func CheckContainer(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, name string) (container *types.ContainerJSON, err error)
- func EnsureBridgeNetwork(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, name string, ...) (id string, err error)
- func EnsureContainerStarted(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, ...) (container *types.ContainerJSON, created bool, err error)
- func EnsureImage(ctx context.Context, ow *rpc.OutputWriter, client *client.Client, ...) (created bool, err error)
- func EnsureVolume(ctx context.Context, log *zap.SugaredLogger, cli *client.Client, ...) (volume *types.Volume, created bool, err error)
- func FindImage(ctx context.Context, ow *rpc.OutputWriter, client *client.Client, name string) (*types.ImageSummary, bool, error)
- func NewBridgeNetwork(ctx context.Context, cli *client.Client, name string, internal bool, ...) (id string, err error)
- func PipeOutput(r io.ReadCloser, w io.Writer) error
- type BuildImageOpts
- type ContainerRef
- type EnsureContainerOpts
- type EnsureVolumeOpts
- type ImageStrategy
- type Manager
- type WorkerFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildImage ¶ added in v0.3.0
func BuildImage(ctx context.Context, ow *rpc.OutputWriter, client *client.Client, opts *BuildImageOpts) error
BuildImage builds a docker image from provided BuildImageOpts or a set of default options. If BuildImageOpts.BuildOpts is filled, these options will be passed to the docker client un-edited. In this case, BuildImageOpts.Name is unused when the image is created. When BuildImageOpts.BuildOpts has nil value, a default set of options will be constructed using the Name, and the constructed options are sent to the docker client. The build output is directed to stdout via PipeOutput.
func CheckBridgeNetwork ¶ added in v0.2.0
func CheckBridgeNetwork(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, name string) ([]types.NetworkResource, error)
func CheckContainer ¶ added in v0.2.0
func CheckContainer(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, name string) (container *types.ContainerJSON, err error)
func EnsureBridgeNetwork ¶
func EnsureContainerStarted ¶ added in v0.4.0
func EnsureContainerStarted(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, opts *EnsureContainerOpts) (container *types.ContainerJSON, created bool, err error)
EnsureContainerStarted ensures there's a container started of the specified kind, resorting to building it if necessary and so indicated.
func EnsureImage ¶ added in v0.3.0
func EnsureImage(ctx context.Context, ow *rpc.OutputWriter, client *client.Client, opts *BuildImageOpts) (created bool, err error)
EnsureImage builds an image only of one does not yet exist. This is a thin wrapper around BuildImage, and the same comments regarding the passed BuildImageOpts applies here. Returns a bool depending on whether the image had to be created and any errors that were encountered.
func EnsureVolume ¶ added in v0.2.0
func EnsureVolume(ctx context.Context, log *zap.SugaredLogger, cli *client.Client, opts *EnsureVolumeOpts) (volume *types.Volume, created bool, err error)
EnsureVolume ensures the volume is created. If another volume exists with the same name, nothing is created, regardless of any other options passed.
func FindImage ¶ added in v0.4.0
func FindImage(ctx context.Context, ow *rpc.OutputWriter, client *client.Client, name string) (*types.ImageSummary, bool, error)
FindImage looks for an image with name `name` in our local daemon.
If found, it returns the image summary and true. If absent, it returns a nil image summary, and false. If an internal error occurs, it returns a nil image summary, false, and a non-nil error.
func NewBridgeNetwork ¶
func PipeOutput ¶
func PipeOutput(r io.ReadCloser, w io.Writer) error
PipeOutput pipes a reader that spits out jsonmessage structs into a writer, usually stdout. It returns normally when the reader is exhausted, or in error if one occurs.
Types ¶
type BuildImageOpts ¶ added in v0.3.0
type BuildImageOpts struct {
Name string // reuired for EnsureImage
BuildCtx string // required
BuildOpts *types.ImageBuildOptions // optional
}
type ContainerRef ¶ added in v0.3.0
Container is a convenient handle for a docker container.
func (*ContainerRef) Exec ¶ added in v0.3.0
func (c *ContainerRef) Exec(ctx context.Context, cmd ...string) error
func (*ContainerRef) Inspect ¶ added in v0.3.0
func (c *ContainerRef) Inspect(ctx context.Context) (types.ContainerJSON, error)
Inspect inspects this docker container.
type EnsureContainerOpts ¶
type EnsureContainerOpts struct {
ContainerName string
ContainerConfig *container.Config
HostConfig *container.HostConfig
NetworkingConfig *network.NetworkingConfig
ImageStrategy ImageStrategy
BuildImageOpts *BuildImageOpts
}
type EnsureVolumeOpts ¶ added in v0.2.0
type EnsureVolumeOpts struct {
Name string
DriverOpts map[string]string
Labels map[string]string
Driver string
}
EnsureVolumeOpts is used to construct the volume request. https://github.com/moby/moby/blob/master/api/types/volume/volume_create.go
type ImageStrategy ¶ added in v0.4.0
type ImageStrategy int
const ( ImageStrategyNone ImageStrategy = iota ImageStrategyPull ImageStrategyBuild )
type Manager ¶ added in v0.3.0
Manager is a convenient wrapper around the docker client.
func NewManager ¶ added in v0.3.0
NewManager connects to the local docker instance and provides a convenient handle for managing containers.
func (*Manager) NewContainerRef ¶ added in v0.3.0
func (m *Manager) NewContainerRef(id string) *ContainerRef
NewContainerRef constructs a reference to a given container.