Documentation

Overview

    Package containers provides utilities for interacting with Docker containers

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var (
    	// ErrNoContainers is the response to indicate that no containers are active
    	ErrNoContainers = errors.New("There are currently no active containers")
    )

    Functions

    func ContainerLogs

    func ContainerLogs(docker *docker.Client, opts LogOptions) (io.ReadCloser, error)

      ContainerLogs get logs ;)

      func GetActiveContainers

      func GetActiveContainers(docker *docker.Client) ([]types.Container, error)

        GetActiveContainers returns all active containers and returns and error if the Daemon is the only active container

        func GetLatestImageTag

        func GetLatestImageTag(ctx context.Context, image Image, min *semver.Version) (*semver.Version, error)

          GetLatestImageTag retrieves the most recent valid semver tag of an image

          func NewDockerClient

          func NewDockerClient() (*docker.Client, error)

            NewDockerClient creates a new Docker Client from ENV values and negotiates the correct API version

            func Prune

            func Prune(docker *docker.Client) error

              Prune clears up unused Docker assets.

              func PruneAll

              func PruneAll(docker *docker.Client, exceptions ...string) error

                PruneAll forcibly removes all images except given exceptions (repo tag names)

                func StartAndWait

                func StartAndWait(cli *docker.Client, containerID string, out io.Writer) error

                  StartAndWait starts and waits for container to exit

                  func StopActiveContainers

                  func StopActiveContainers(docker *docker.Client, out io.Writer) error

                    StopActiveContainers kills all active project containers (ie not including daemon)

                    func StreamContainerLogs

                    func StreamContainerLogs(client *docker.Client, id string, out io.Writer,
                    	stop chan struct{}) error

                      StreamContainerLogs streams logs from given container ID. Best used as a goroutine.

                      func Wait

                      func Wait(cli *docker.Client, id string, stop chan struct{}) (int64, error)

                        Wait blocks until given container ID stops

                        Types

                        type ContainerStopper

                        type ContainerStopper func(*docker.Client, io.Writer) error

                          ContainerStopper is a function interface

                          type Image

                          type Image struct {
                          	Registry   string
                          	Repository string
                          }

                            Image describes a Docker image. An empty registry defaults to DockerHub

                            type LogOptions

                            type LogOptions struct {
                            	Container    string
                            	Stream       bool
                            	Detailed     bool
                            	NoTimestamps bool
                            	Entries      int
                            }

                              LogOptions is used to configure retrieved container logs