containers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 15 Imported by: 4

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 added in v0.6.1

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 added in v0.4.2

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

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

func Prune added in v0.4.1

func Prune(docker *docker.Client) error

Prune clears up unused Docker assets.

func PruneAll added in v0.4.1

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

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

func StartAndWait added in v0.4.3

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 added in v0.4.2

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 added in v0.7.0

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

Jump to

Keyboard shortcuts

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