inertia: github.com/ubclaunchpad/inertia/daemon/inertiad/containers Index | Files

package containers

import "github.com/ubclaunchpad/inertia/daemon/inertiad/containers"

Package containers provides utilities for interacting with Docker containers

Index

Package Files

containers.go doc.go docker.go images.go

Variables

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

func ContainerLogs Uses

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

ContainerLogs get logs ;)

func GetActiveContainers Uses

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 Uses

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 Uses

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

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

func Prune Uses

func Prune(docker *docker.Client) error

Prune clears up unused Docker assets.

func PruneAll Uses

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

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

func StartAndWait Uses

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

StartAndWait starts and waits for container to exit

func StopActiveContainers Uses

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

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

func StreamContainerLogs Uses

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 Uses

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

Wait blocks until given container ID stops

type ContainerStopper Uses

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

ContainerStopper is a function interface

type Image Uses

type Image struct {
    Registry   string
    Repository string
}

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

type LogOptions Uses

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

LogOptions is used to configure retrieved container logs

Package containers imports 15 packages (graph) and is imported by 5 packages. Updated 2020-12-09. Refresh now. Tools for package owners.