docker

package
v0.0.0-...-31e061d Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package docker provides a client for interacting with the local Docker daemon. This currently shells out to the Docker CLI, but could use the HTTP API directly in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageRefRegistry

func ImageRefRegistry(s string) string

ImageRefRegistry parses the registry (everything before the first slash) from a Docker image reference or name.

func ParseImageRef

func ParseImageRef(s string) (name, tag, digest string)

ParseImageRef parses a Docker image reference, as documented in https://godoc.org/github.com/docker/distribution/reference. It permits some looseness in characters, and in particular, permits the empty name form ":foo". It is guaranteed that name + tag + digest == s.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for a Docker daemon. The zero value is a Docker client that uses the current process's environment. Methods on Client are safe to call concurrently from multiple goroutines.

func New

func New(env []string) *Client

New creates a new client with the given environment variables. Calling docker.New(nil) is the same as new(docker.Client) and uses the current process's environment.

func (*Client) Build

func (c *Client) Build(ctx context.Context, imageRefs []string, dir string, buildOutput io.Writer) error

Build builds a Docker image from a source directory, optionally tagging it with the given image references. Output is streamed to the buildOutput writer.

func (*Client) ListImages

func (c *Client) ListImages(ctx context.Context, filterRef string) ([]*Image, error)

ListImages lists images the Docker daemon has stored locally that match filterRef.

func (*Client) Login

func (c *Client) Login(ctx context.Context, registry, username, password string) error

Login stores the credentials for the given remote registry. This is used for Docker push and pull.

func (*Client) Push

func (c *Client) Push(ctx context.Context, imageRef string, progressOutput io.Writer) error

Push pushes the image named by imageRef from the local Docker daemon to its remote registry, as determined by the reference's repository name. Progress information is written to the progressOutput writer.

func (*Client) Start

func (c *Client) Start(ctx context.Context, imageRef string, opts *RunOptions) (string, error)

Start starts a Docker container and returns its ID.

func (*Client) Tag

func (c *Client) Tag(ctx context.Context, srcImageRef, dstImageRef string) error

Tag adds a new tag to a given image reference.

type Image

type Image struct {
	// ID is the randomly generated ID of the image.
	// See https://windsock.io/explaining-docker-image-ids/
	ID string
	// Repository is the name component of a Docker image reference.
	// It may be empty if the image has no tags.
	// See https://godoc.org/github.com/docker/distribution/reference
	Repository string
	// Tag is the tag component of a Docker image reference.
	// It will be empty if the image has no tags.
	// See https://godoc.org/github.com/docker/distribution/reference
	Tag string
	// Digest is the content-based hash of the image.
	// It may be empty.
	Digest string
	// CreatedAt is the time the image was built.
	CreatedAt time.Time
}

Image stores metadata about a Docker image.

type RunOptions

type RunOptions struct {
	Args         []string
	Env          []string
	RemoveOnExit bool
	Publish      []string
}

RunOptions holds optional parameters for starting a Docker container.

Jump to

Keyboard shortcuts

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