dockercommand

package module
v0.0.0-...-097a94c Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2016 License: MIT Imports: 9 Imported by: 13

README

go-dockercommand

Travis

Go Docker Command is a Go library that provides a fluent interface to manage Docker containers, in the manner of the Docker CLI

We use the great fsouza/go-dockerclient to communicate with the Docker engine.

Note: Requires at least go 1.3

Examples

Start a nginx container with go-dockercommand

package main

import (
	"fmt"

	docker "github.com/bywan/go-dockercommand"
)

func main() {
	// Create go-dockercommand client
	client, err := docker.NewDocker("")
	if err != nil {
		fmt.Printf("Error creating go-dockercommand client, error is: %v", err)
	}

	// Create a nginx container
	_, err = client.Run(&docker.RunOptions{
		Name:   "test",
		Image:  "nginx",
		Detach: true,
	})

	if err != nil {
		fmt.Printf("Error Starting Docker Container, error is: %v", err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions

type BuildOptions struct {
	// Relative path of the Dockerfile from the Path
	Dockerfile string
	// The context dir for the docker build
	Path string
	// The repository name
	Tag string
	//The Build args
	BuildArgs map[string]string
	//Build without cache
	NoCache bool
}

type Client

type Client interface {
	ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
	ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)
	BuildImage(opts docker.BuildImageOptions) error
	InspectContainer(id string) (*docker.Container, error)
	PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
	RemoveContainer(opts docker.RemoveContainerOptions) error
	CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
	StartContainer(id string, hostConfig *docker.HostConfig) error
	WaitContainer(id string) (int, error)
	StopContainer(id string, timeout uint) error
	InspectImage(name string) (*docker.Image, error)
	Logs(opts docker.LogsOptions) error
	ListNetworks() ([]docker.Network, error)
	CreateNetwork(docker.CreateNetworkOptions) (*docker.Network, error)
}

type Container

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

func (*Container) ID

func (c *Container) ID() string

func (*Container) Inspect

func (c *Container) Inspect() (*docker.Container, error)

func (*Container) Logs

func (c *Container) Logs(prefix string)

func (*Container) LogsWith

func (c *Container) LogsWith(prefix string, logger *log.Logger)

func (*Container) Remove

func (c *Container) Remove(opts *RemoveOptions) error

func (*Container) Stop

func (c *Container) Stop(timeout uint) error

func (*Container) StreamLogs

func (c *Container) StreamLogs(w io.Writer)

func (*Container) Wait

func (c *Container) Wait() (int, error)

type Docker

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

func NewDocker

func NewDocker(endpoint string) (*Docker, error)

func NewDockerForTest

func NewDockerForTest() (*Docker, error)

func (*Docker) Build

func (dock *Docker) Build(options *BuildOptions) error

func (*Docker) BuildWithLogger

func (dock *Docker) BuildWithLogger(options *BuildOptions, logger *log.Logger) error

func (*Docker) CreateNetwork

func (dock *Docker) CreateNetwork(opts docker.CreateNetworkOptions) (*docker.Network, error)

func (*Docker) Images

func (dock *Docker) Images(options *ImagesOptions) ([]docker.APIImages, error)

func (*Docker) Inspect

func (dock *Docker) Inspect(containerID string) (*docker.Container, error)

func (*Docker) Networks

func (dock *Docker) Networks() ([]docker.Network, error)

func (*Docker) Ps

func (dock *Docker) Ps(options *PsOptions) ([]docker.APIContainers, error)

func (*Docker) Pull

func (dock *Docker) Pull(options *PullOptions) error

func (*Docker) Rm

func (dock *Docker) Rm(options *RmOptions) error

func (*Docker) Run

func (dock *Docker) Run(options *RunOptions) (*Container, error)

func (*Docker) Start

func (dock *Docker) Start(options *StartOptions) error

func (*Docker) Stop

func (dock *Docker) Stop(options *StopOptions) error

type FsouzaClient

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

func (*FsouzaClient) BuildImage

func (c *FsouzaClient) BuildImage(opts docker.BuildImageOptions) error

func (*FsouzaClient) CreateContainer

func (c *FsouzaClient) CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)

func (*FsouzaClient) CreateNetwork

func (c *FsouzaClient) CreateNetwork(opts docker.CreateNetworkOptions) (*docker.Network, error)

func (*FsouzaClient) InspectContainer

func (c *FsouzaClient) InspectContainer(id string) (*docker.Container, error)

func (*FsouzaClient) InspectImage

func (c *FsouzaClient) InspectImage(name string) (*docker.Image, error)

func (*FsouzaClient) ListContainers

func (c *FsouzaClient) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)

func (*FsouzaClient) ListImages

func (c *FsouzaClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)

func (*FsouzaClient) ListNetworks

func (c *FsouzaClient) ListNetworks() ([]docker.Network, error)

func (*FsouzaClient) Logs

func (c *FsouzaClient) Logs(opts docker.LogsOptions) error

func (*FsouzaClient) PullImage

func (*FsouzaClient) RemoveContainer

func (c *FsouzaClient) RemoveContainer(opts docker.RemoveContainerOptions) error

func (*FsouzaClient) StartContainer

func (c *FsouzaClient) StartContainer(id string, hostConfig *docker.HostConfig) error

func (*FsouzaClient) StopContainer

func (c *FsouzaClient) StopContainer(id string, timeout uint) error

func (*FsouzaClient) WaitContainer

func (c *FsouzaClient) WaitContainer(id string) (int, error)

type ImagesOptions

type ImagesOptions struct {
	All     bool
	Filters map[string][]string
	Digests bool
}

type PsOptions

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

type PullOptions

type PullOptions struct {
	Image string
}

type RemoveOptions

type RemoveOptions struct {
	RemoveVolumes bool
	Force         bool
}

type RmOptions

type RmOptions struct {
	Container     []string
	Force         bool
	RemoveVolumes bool
}

type RunOptions

type RunOptions struct {
	Name                string
	Image               string
	Cmd                 []string
	VolumeBinds         []string
	Links               []string
	PublishAllPorts     bool
	PortBindings        map[docker.Port][]docker.PortBinding
	Detach              bool
	Env                 map[string]string
	LoggingDriver       string
	LoggingDriverConfig map[string]string
	NetworkMode         string
}

type Scanner

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

func NewScanner

func NewScanner(reader io.Reader) *Scanner

func (*Scanner) Err

func (s *Scanner) Err() error

func (*Scanner) Scan

func (s *Scanner) Scan() bool

func (*Scanner) Text

func (s *Scanner) Text() string

type StartOptions

type StartOptions struct {
	ID              string
	VolumeBinds     []string
	Links           []string
	PublishAllPorts bool
	PortBindings    map[docker.Port][]docker.PortBinding
	NetworkMode     string
	LogConfig       docker.LogConfig
}

type StopOptions

type StopOptions struct {
	ID      string
	Timeout uint
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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