dockerutil

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package dockerutil provides Docker-related utility functions. These are very specific to Lever.

Index

Constants

View Source
const PackageName = "dockerutil"

PackageName is the name of this package.

Variables

View Source
var (
	// DockerSwarmFlag is the docker swarm endpoint.
	DockerSwarmFlag = config.DeclareString(
		PackageName, "dockerSwarm", "unix:///var/run/docker.sock")
	// DockerLocalFlag is the local docker endpoint.
	DockerLocalFlag = config.DeclareString(
		PackageName, "dockerLocal", "unix:///var/run/docker.sock")

	// LeverCodeHostDirFlag is the location on the host (outside docker) of the
	// mounted customer code directory, containing all code from all
	// environments and services.
	LeverCodeHostDirFlag = config.DeclareString(
		PackageName, "leverCodeHostDir", "/tmp/leveros/custcodetree")

	// DisableRemoveContainerFlag causes Lever containers to not be
	// removed (on errors, on exit etc).
	DisableRemoveContainerFlag = config.DeclareBool(
		PackageName, "disableRemoveContainer")
)

Functions

func CodeDirPath

func CodeDirPath(environment, service string, codeVersion int64) string

CodeDirPath returns the path within the docker container that the code for a given service version is found at.

func ConnectToDockerEnvNetwork

func ConnectToDockerEnvNetwork(
	docker *dockerapi.Client, containerID, networkID string) (
	containerIPv4 string, err error)

ConnectToDockerEnvNetwork connects the provided container ID to the network bridge of an environment and returns the IPv4 of the container within that network.

func CreateDockerEnvNetwork

func CreateDockerEnvNetwork(
	docker *dockerapi.Client, environment string) (
	networkID string, networkIPv4 string, ownIPv4 string, err error)

CreateDockerEnvNetwork creates the network bridge for an environment. Returns the network IPv4 of the bridge (useful for listening for connections from that bridge) as well as our own IPv4 on that network.

func DisconnectFromDockerEnvNetwork

func DisconnectFromDockerEnvNetwork(
	docker *dockerapi.Client, containerID, networkID string) error

DisconnectFromDockerEnvNetwork disconnects the provided container ID from the network bridge of an environment.

func GetDockerEnvIPv4

func GetDockerEnvIPv4(
	docker *dockerapi.Client, containerID, networkID string) (string, error)

GetDockerEnvIPv4 returns the IPv4 of a container within the network bridge of an environment.

func GetOwnContainerID

func GetOwnContainerID() string

GetOwnContainerID returns the container ID of the currently running container. This assumes access to the local docker.

func GetOwnEnvIPv4

func GetOwnEnvIPv4(
	docker *dockerapi.Client, networkID string) (string, error)

GetOwnEnvIPv4 returns the IPv4 address within the network bridge of an environment for the current process.

func HostCodeDirPath

func HostCodeDirPath(environment, service string, codeVersion int64) string

HostCodeDirPath returns the path on the docker host that the code for a given service version is found at.

func NewDockerLocal

func NewDockerLocal() (docker *dockerapi.Client)

NewDockerLocal returns a client for the local docker.

func NewDockerSwarm

func NewDockerSwarm() (docker *dockerapi.Client)

NewDockerSwarm returns a client for the docker swarm.

func RemoveDockerContainer

func RemoveDockerContainer(docker *dockerapi.Client, containerID string) error

RemoveDockerContainer removes a Docker container which has stopped.

func RemoveDockerEnvNetwork

func RemoveDockerEnvNetwork(
	docker *dockerapi.Client, networkID string) error

RemoveDockerEnvNetwork removes the network bridge for an environment.

func StartDockerContainer

func StartDockerContainer(
	docker *dockerapi.Client, environment string, service string,
	instanceID string, codeVersion int64, isAdmin bool,
	leverConfig *core.LeverConfig) (
	containerID string, node string, err error)

StartDockerContainer starts a new Lever container for the specified environment and service.

Types

This section is empty.

Jump to

Keyboard shortcuts

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