docker

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DockerInfo = func() string {
	out, err := exec.Command("docker", "info").Output()
	if err != nil {
		panic(err.Error())
	} else {
		return string(out)
	}
}

DockerInfo shells out the command 'docker -info', returning the information if the command is successful and panicking if not.

View Source
var DockerPull = func(image string) {
	out := exec.Command("docker", "pull", image)
	out.Stdin = os.Stdin
	out.Stdout = os.Stderr
	out.Stderr = os.Stderr
	out.Run()
}

DockerPull shells out the command 'docker pull {{image}}' where image is the name of a Docker image to retrieve from the remote Docker repository.

View Source
var DockerVersion = func() string {
	out, err := exec.Command("docker", "-v").Output()
	if err != nil {
		panic(err.Error())
	} else {
		return string(out)
	}
}

DockerVersion shells out the command 'docker -v', returning the version information if the command is successful, and panicking if not.

Functions

func ExtractDockerVersion

func ExtractDockerVersion(version string) (int, int, int)

ExtractDockerVersion takes a Docker version string in the format: 'Docker version 1.0.0, build abcdef0', extracts the major, minor and patch versions and returns these as a tuple. If the string does not match, panic.

func IsDockerPresent

func IsDockerPresent() (present bool)

IsDockerPresent tests for the presence of Docker by invoking DockerVersion to get the version of Docker if available, and then attempting to parse the version with ExtractDocker version. This function will return true only if neither of these functions panics.

func IsDockerRunning

func IsDockerRunning() (running bool)

IsDockerRunning tests whether Docker is running by invoking DockerInfo which will only return information if Docker is up. This function will return true if DockerInfo does not panic.

func RunAnonymousContainer

func RunAnonymousContainer(image string, extraDockerArgs []string, entrypointArgs []string)

RunAnonymousContainer shells out the command: 'docker run --rm {{extraDockerArgs}} -t {{image}} {{entrypointArgs}}'. This will run an anonymouse Docker container with the specified image, with any extra arguments to pass to Docker, for example directories to mount, as well as arguments to pass to the image's entrypoint.

Types

This section is empty.

Jump to

Keyboard shortcuts

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