Documentation
¶
Index ¶
- func AttachAndWait(dockerClient *docker.Client, containerID string, ...)
- func AttachToContainerOpts(containerID string, stdout io.Writer, stderr io.Writer) docker.AttachToContainerOptions
- func ClientOrDie() *docker.Client
- func CmdStr(co docker.CreateContainerOptions, hc docker.HostConfig) string
- func ContainerGopath(gopath, packageName string) string
- func CreateAndStartContainerOpts(imageName, containerName string, cmd []string, env []string, ...) (docker.CreateContainerOptions, docker.HostConfig)
- func EnsureImage(dockerCl *dlib.Client, image string, ifNotExists func() (io.Writer, error)) error
- func GetImages(dockerCl *dlib.Client, img *Image) ([]dlib.APIImages, error)
- func NewContainerName(prefix string, cwd string) string
- func Run(cl *docker.Client, image *Image, taskName, cwd, containerMount, cmd string, ...)
- type ChanWriter
- type Image
- type Log
- type PullImageStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachAndWait ¶
func AttachAndWait( dockerClient *docker.Client, containerID string, attachOpts docker.AttachToContainerOptions, exitCodeCh chan<- int, errCh chan<- error, )
AttachAndWait attaches to and waits for the container with the given ID using the given client, according to the given options. This function should be started in a goroutine. exitCodeCh will receive if the container completed execution. errCh may receive if the attach couldn't be completed or the container didn't complete properly. if errCh receives, exitCodeCh will not receive
func AttachToContainerOpts ¶
func AttachToContainerOpts(containerID string, stdout io.Writer, stderr io.Writer) docker.AttachToContainerOptions
AttachContainerOpts returns docker.AttachToContainerOptions with output and error streams turned on as well as logs. the returned io.Reader will output both stdout and stderr
func ClientOrDie ¶
ClientOrDie creates a new Docker client. If one couldn't be created, logs and error and exits with status code 1
func CmdStr ¶
func CmdStr(co docker.CreateContainerOptions, hc docker.HostConfig) string
CmdStr returns the 'docker run' command that you'd execute to achieve the run configuration represented by co and hc
func ContainerGopath ¶
func CreateAndStartContainerOpts ¶
func CreateAndStartContainerOpts( imageName, containerName string, cmd []string, env []string, mounts []docker.Mount, workDir string, ) (docker.CreateContainerOptions, docker.HostConfig)
CreateAndStartContainerOpts creates a container from imageName with the name containerName. The container will execute cmd with the given enviroment variables (env). The container will specify volumes as each 'Source' field in mounts, and bind each mount.Source to each mount.Destination. Finally, the container will set GOPATH to the given containerGoPath variable.
func EnsureImage ¶
EnsureImage ensures that image is on the docker daemon pointed to by dockerCl. If it doesn't, then it attempts to pull the image. If the image doesn't exist, calls ifNotExists before proceeding to download the image. If ifNotExists returns an error, immediately returns that error. Otherwise, returns any error pulling the image.
func GetImages ¶
GetImages gets images matching img from dockerCl. Returns an empty slice and a non-nil error if there was an error talking to the daemon
func NewContainerName ¶
NewContainerName returns a new, unique container name that includes prefix and cwd
func Run ¶
func Run( cl *docker.Client, image *Image, taskName, cwd, containerMount, cmd string, env []string, rmContainerCh chan<- func(), stdOut chan<- Log, stdErr chan<- Log, exitCodeCh chan<- int, errCh chan<- error, )
Run runs cmd in the given image using the docker client cl. It mounts cwd into containerMount in the running container and sends on the following channels:
- rmContainerCh: a function closure that the receiver should call, after they receive on errCh or exitCodeCh, to remove the container. this is commonly done with a 'defer' - stdOut: all logs from STDOUT in the container. this may never receive - stdErr: all logs from STDERR in the container. this may never receive - exitCodeCh: the exit code of the container - errCh: any error in setting up or running the container. if errCh receives, exitCodeCh may not receive
Types ¶
type ChanWriter ¶
type ChanWriter struct {
// contains filtered or unexported fields
}
ChanWriter returns an io.Writer that sends all of its writes as log messages to ch
func NewChanWriter ¶
func NewChanWriter(ch chan<- Log) *ChanWriter
NewChanWriter creates a new ChanWriter ready to accept writes and forward
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents a single image name, including all information about its registry, repository and tag
func ParseImageFromName ¶
ParseImageFromName parses a raw image name string into an Image
func (Image) FullWithoutTag ¶
FullWithoutTag returns the full image name without its tag
type PullImageStatus ¶
type PullImageStatus interface {
String() string
}
PullImageStatus represents the status of an image pull