container

package
v0.0.0-...-01d9fd7 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MinimalEnv used to set exec environment for command invocation inside lxc
	MinimalEnv = []string{
		"SHELL=/bin/bash",
		"USER=root",
		"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
		"PWD=/root",
		"EDITOR=vim",
		"LANG=en_US.UTF-8",
		"HOME=/root",
		"LANGUAGE=en_US",
		"LOGNAME=root",
	}
)

Functions

func TagToName

func TagToName(tag string) string

TagToName converts Dockerfile's FROM target to a valid lxc container name

func UUID

func UUID() (string, error)

UUID generates uuid

Types

type Builder

type Builder struct {
	Name       string
	Volumes    []string
	Statements []string
	RootDir    string
}

Builder represents a container build environment

func NewBuilder

func NewBuilder(name string) *Builder

NewBuilder returns a Builder struct

func (*Builder) Build

func (b *Builder) Build() (*Container, error)

Build creates a new container from build instructions and return the container struct

func (*Builder) Parse

func (b *Builder) Parse(file string) error

Parse take a dockerfile like DSL file path and populates build instructions

type Container

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

Container represents a container with some metadata

func NewContainer

func NewContainer(name string) (*Container, error)

NewContainer returns a container struct

func (*Container) BindMount

func (c *Container) BindMount(volume string) error

BindMount sets up bind mount for the container, where the input string specifies the host directory, container directory and mount options separated by ":"

func (*Container) Create

func (c *Container) Create(parent string) error

Create creates new container by clonin parent

func (*Container) Destroy

func (c *Container) Destroy() error

Destroy destroys the container

func (*Container) RunCommand

func (c *Container) RunCommand(command []string) error

RunCommand runs a command inside the container with enviroment, workdir, user as specified by its manifest

func (*Container) Start

func (c *Container) Start() error

Start starts the container and wait for IP allocation

func (*Container) Stop

func (c *Container) Stop() error

Stop stops the container

func (*Container) UpdateUTS

func (c *Container) UpdateUTS(name string) error

UpdateUTS changes the container's nameand rootfs path

type Group

type Group struct {
	Version string            `yaml:"version"`
	Members map[string]Member `yaml:"services"`
}

Group represents a set of containers

func GroupFromYAML

func GroupFromYAML(file string) (*Group, error)

GroupFromYAML initializes a Group struct from yaml file

func (*Group) Create

func (g *Group) Create() error

Create creates the containes defined inside the group

type Image

type Image struct {
	Path string
	// contains filtered or unexported fields
}

Image represent a container image, which holds rootfs and metadata

func NewImage

func NewImage(name, path string) (*Image, error)

NewImage Returns a Image struct for the provided container name and image path

func (*Image) Create

func (i *Image) Create(sudo bool) error

Create creates a new tarball image from a container. sudo is used for invoking tar, if set to true

func (*Image) Decompress

func (i *Image) Decompress(sudo bool) error

Decompress decompress the image into a container

func (*Image) Publish

func (i *Image) Publish(region, bucket, key string) error

Publish publishes the image in s3

type Manifest

type Manifest struct {
	Labels       map[string]string
	Maintainers  []string
	ExposedPorts []uint64
	EntryPoint   []string
	Env          []string
	User         string
	WorkDir      string
}

Manifest represents metadata about a container

func (*Manifest) Load

func (m *Manifest) Load(name string) error

Load loads manifest details from an yaml file

type Member

type Member struct {
	Build         string
	ContainerName string `yaml:"container_name"`
	Hostname      string `yaml:"hostname"`
	Command       string
	Volumes       []string
	User          string
	Environment   []string
	Ports         []string
	// contains filtered or unexported fields
}

Member represents an individual member in a container group

func (*Member) Create

func (m *Member) Create(name string) error

Create creates a container from member specification

func (*Member) RunCommand

func (m *Member) RunCommand() error

RunCommand runs the member's specified command inside it representative container

Jump to

Keyboard shortcuts

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