containerdefs

package
v0.0.0-...-8b8e185 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessContainerDefinitions

func ProcessContainerDefinitions(conf *config.Configuration, cdefs []*ContainerDefinition) error

ProcessContainerDefinitions runs a goroutine for each definition, pulling images, validating them and starting containers if necessary.

func RemoveRedundantContainers

func RemoveRedundantContainers(cdefs []*ContainerDefinition) error

RemoveRedundantContainers loops through all running docker containers and stops/removes any that whose name doesn't match the name of one of the container definitions passed into the function.

Types

type ContainerDefinition

type ContainerDefinition struct {
	// ContainerName controls the user-specified part of the name oneill will
	// give to the container at startup time. oneill uses a simple convention
	// when naming containers `{prefix}-{container-name}`.
	// `prefix` specifies whether this container is an application or service
	// container, and `container-name` is specified by the user in a container
	// definition.
	ContainerName string `yaml:"container_name"`

	// RepoTag controls the container that will be pulled and run for this
	// container definition. This is in the same format as you would pass to
	// `docker run`, e.g. `locahost:5000/myimage:latest`, `nginx`,
	// `ubuntu:14.04`, `my.private.repo/myotherimage`
	RepoTag string `yaml:"repo_tag"`

	// Env is a slice containing arbitrary environment variables that get
	// passed to new containers at runtime. Variables set here will override
	// environment variables set anywhere else (including those set by oneill
	// itself), so use with caution.
	Env dockerclient.Env `yaml:"env"`

	// should persistence be enabled for this container? default off as we
	// don't want to encourage people to use persistence (whilst acknowledging
	// that it is necessary in some situations).
	PersistenceEnabled bool `yaml:"persistence_enabled"`

	// should the docker control socket be bind-mounted into this container?
	// this is useful for service containers that need to be able to see or
	// control what other containers are doing (nginx service, fluentd
	// service, etc. need this functionality).
	DockerControlEnabled bool `yaml:"docker_control_enabled"`

	// service containers allow an explicit port mapping as some services need
	// to be exposed on specific ports to be useful e.g. nginx on 80/443 for
	// serving http. Regular containers do not need this functionality. Keys
	// are host port numbers and values are the internal port numbers that
	// should be exposed.
	PortMapping map[int]int `yaml:"port_mapping"`
}

func LoadContainerDefinitions

func LoadContainerDefinitions(loader DefinitionLoader) ([]*ContainerDefinition, error)

LoadContainerDefinitions scans a local directory (might have been passed from the command line) for container definitions, reads them into memory and unmarshalls them into ContainerDefinition structs.

func (*ContainerDefinition) AlreadyRunning

func (cd *ContainerDefinition) AlreadyRunning(persistenceDir string) bool

AlreadyRunning checks whether a container is already running that matches *exactly* this container definition.

func (*ContainerDefinition) RemoveContainer

func (cd *ContainerDefinition) RemoveContainer() error

RemoveContainer removes a container with the same name as contained within this definition if one exists.

func (*ContainerDefinition) StartContainer

func (cd *ContainerDefinition) StartContainer(persistenceDir string) error

StartContainer assembles the appropriate options structs and starts a new container that matches the container definition.

func (*ContainerDefinition) Validate

func (cd *ContainerDefinition) Validate() bool

Validate checks that a container definition is internally consistent and that its configuration is valid in isolation. Validation of container definitions as a whole group happens (e.g. testing for uniqueness of container names or port mappings) elsewhere in the app.

type DefinitionLoader

type DefinitionLoader interface {
	LoadContainerDefinitions() ([]*ContainerDefinition, error)
	ValidateURI() error
}

Jump to

Keyboard shortcuts

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