dockerclient

package
v0.0.0-...-b425644 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

A docker client library.

Index

Constants

View Source
const FAKE_AUTH = `
{
	"Auth": "fakeauth",
	"Email": "fake@email.xx"
}
`

Variables

View Source
var ErrorNotFound = fmt.Errorf("resource not found")

Functions

func HandlePullImageMessage

func HandlePullImageMessage(msg *JSONMessage)

Types

type AttachOptions

type AttachOptions struct {
	Logs   bool
	Stream bool
	Stdout io.Writer
	Stderr io.Writer
}

func (*AttachOptions) Encode

func (opts *AttachOptions) Encode() string

type BuildImageOptions

type BuildImageOptions struct {
	Tag     string
	Quite   bool
	NoCache bool

	Callback func(s *JSONMessage)
}

type BuildResponse

type BuildResponse []*JSONMessage

func (BuildResponse) ImageId

func (rsp BuildResponse) ImageId() string

func (BuildResponse) Last

func (rsp BuildResponse) Last() *JSONMessage

type Client

type Client struct {
	Address string
	Client  *http.Client // http client used to send requests to the host.
}

func New

func New(addr string) *Client

Create a new connection to a docker host reachable at the given host and port.

func (*Client) AttachContainer

func (dh *Client) AttachContainer(containerId string, opts *AttachOptions) (e error)

Attach to the given container with the given writer.

func (*Client) Build

func (dh *Client) Build(r io.Reader, opts *BuildImageOptions) (imageId string, e error)

Build a container image from a tar or tar.gz Reader

func (*Client) BuildDockerfile

func (dh *Client) BuildDockerfile(dockerfile string, opts *BuildImageOptions) (imageId string, e error)

Create a new image from the given dockerfile. If name is non empty the new image is named accordingly. If a writer is given it is used to send the docker output to.

func (*Client) Container

func (dh *Client) Container(containerId string) (containerInfo *docker.ContainerInfo, e error)

Get the information for the container with the given id.

func (*Client) Containers

func (dh *Client) Containers() (containers []*docker.Container, e error)

Get a list of all ontainers available on the host.

func (*Client) CreateContainer

func (dh *Client) CreateContainer(options *docker.ContainerConfig, name string) (containerId string, e error)

For the given image name and the given container configuration, create a container. If the image name deosn't contain a tag "latest" is used by default.

func (*Client) DeleteImage

func (dh *Client) DeleteImage(name string) error

Delete the given image from the docker host.

func (*Client) HostInfo

func (dh *Client) HostInfo() (*DockerHostInfo, error)

func (*Client) ImageDetails

func (dh *Client) ImageDetails(id string) (imageDetails *docker.ImageDetails, e error)

Get the details for image with the given id (either hash or name).

func (*Client) ImageHistory

func (dh *Client) ImageHistory(id string) (imageHistory *docker.ImageHistory, e error)

Get the given image's history.

func (*Client) Images

func (dh *Client) Images() (images []*docker.Image, e error)

Get the list of all images available on the this host.

func (*Client) ListContainers

func (dh *Client) ListContainers(opts *ListContainersOptions) (containers []*docker.Container, e error)

func (*Client) PullFromImage

func (dh *Client) PullFromImage(image string, handler func(*JSONMessage)) error

func (*Client) PullImage

func (dh *Client) PullImage(name string) error

Pull the given image from the registry (part of the image name).

func (*Client) PushImage

func (dh *Client) PushImage(name string, opts *PushImageOptions) error

Push the given image to the registry. The name should be <registry>/<repository>.

func (*Client) RemoveContainer

func (dh *Client) RemoveContainer(containerId string) error

func (*Client) StartContainer

func (dh *Client) StartContainer(containerId string, hostConfig *docker.HostConfig) (e error)

Start the container with the given identifier. The hostConfig can safely be set to nil to use the defaults.

func (*Client) StopContainer

func (dh *Client) StopContainer(containerId string) (e error)

Kill the container with the given identifier.

func (*Client) TagImage

func (dh *Client) TagImage(imageId, repository, tag string) (e error)

Tag the image with the given repository and tag. The tag is optional.

type DockerHostInfo

type DockerHostInfo struct {
	Containers         int
	Images             int
	Driver             string
	DriverStatus       [][]string
	ExecutionDriver    string
	KernelVersion      string
	NCPU               int
	MemTotal           int
	Name               string
	ID                 string
	NFd                int
	NGoroutines        int
	NEventsListener    int
	InitPath           string
	InitSha1           string
	IndexServerAddress string
	MemoryLimit        int
	SwapLimit          int
	Labels             []string
	DockerRootDir      string
	OperatingSystem    string
}

type ErrorDetail

type ErrorDetail struct {
	Code    int
	Message string
}

type JSONError

type JSONError struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type JSONMessage

type JSONMessage struct {
	Stream   string        `json:"stream,omitempty"`
	Status   string        `json:"status,omitempty"`
	Progress *JSONProgress `json:"progressDetail,omitempty"`
	Id       string        `json:"id,omitempty"`
	From     string        `json:"from,omitempty"`
	Time     int64         `json:"time,omitempty"`
	Error    *JSONError    `json:"errorDetail,omitempty"`
}

func (*JSONMessage) Err

func (msg *JSONMessage) Err() error

type JSONProgress

type JSONProgress struct {
	Current int   `json:"current,omitempty"`
	Total   int   `json:"total,omitempty"`
	Start   int64 `json:"start,omitempty"`
	// contains filtered or unexported fields
}

type ListContainersOptions

type ListContainersOptions struct {
	All    bool
	Limit  int
	Since  string
	Before string
	Size   bool
}

func (*ListContainersOptions) Encode

func (opts *ListContainersOptions) Encode() string

type ProgressDetail

type ProgressDetail struct {
	Current int64
	Total   int64
	Start   int64
}

type PushImageOptions

type PushImageOptions struct {
	Callback func(s *JSONMessage)
}

Directories

Path Synopsis
docker related datastructures.
docker related datastructures.

Jump to

Keyboard shortcuts

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