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 ¶
- func ImageRefRegistry(s string) string
- func ParseImageRef(s string) (name, tag, digest string)
- type Client
- func (c *Client) Build(ctx context.Context, imageRefs []string, dir string, buildOutput io.Writer) error
- func (c *Client) ListImages(ctx context.Context, filterRef string) ([]*Image, error)
- func (c *Client) Login(ctx context.Context, registry, username, password string) error
- func (c *Client) Push(ctx context.Context, imageRef string, progressOutput io.Writer) error
- func (c *Client) Start(ctx context.Context, imageRef string, opts *RunOptions) (string, error)
- func (c *Client) Tag(ctx context.Context, srcImageRef, dstImageRef string) error
- type Image
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImageRefRegistry ¶
ImageRefRegistry parses the registry (everything before the first slash) from a Docker image reference or name.
func ParseImageRef ¶
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 ¶
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 ¶
ListImages lists images the Docker daemon has stored locally that match filterRef.
func (*Client) Login ¶
Login stores the credentials for the given remote registry. This is used for Docker push and pull.
func (*Client) Push ¶
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 ¶
Start starts a Docker container and returns its ID.
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.