docker
v1.1.1
Documentation
pkg.go.dev ↗Package docker providers an implementation of a Driver driver for job execution. Each job executed will be done in a separate container, a volume is used to persist state across these containers.
Functions
Init
func Init(w io.Writer, cfg driver.Config) runner.Driver
Init initializes a new driver for Docker using the given io.Writer, and applying the given driver.Config.
Types
Config
type Config struct {
Host string // The host running the Docker daemon.
Version string // The version of the Docker API.
Image string // The container image to use.
Workspace string // The workspace in the container to mount the volume to.
}
Config is the struct used for initializing a new Docker driver for build execution.
Config.Apply
func (cfg *Config) Apply(d runner.Driver)
Config.Merge
func (cfg *Config) Merge(m map[string]string) driver.Config
Driver
type Driver struct {
io.Writer
Host string // Host is the host of the Docker registry to use.
Version string // Version is the Docker API version to use.
Image string // Image is the name of the image to use in the Docker container.
// Workspace specifies location on the Driver container to mount a volume
// to so state can be persisted.
Workspace string
// contains filtered or unexported fields
}
Driver provides an implementation of the runner.Dirver interface for running jobs within a Docker container.
Driver.Create
func (d *Driver) Create(c context.Context, env []string, objs runner.Passthrough, p runner.Placer) error
Create will create a volume, and pull down the configured image. The client to the Driver daemon is derived from the environment. Once the client has been established, the image volume is created, and the image is pulled down from the repository.
Driver.Destroy
func (d *Driver) Destroy()
Destroy will remove all containers created during job execution, and the volume. All of these operations are forced.
Driver.Execute
func (d *Driver) Execute(j *runner.Job, c runner.Collector)
Execute performs the given runner.Job in a Driver container. Each job is turned into a shell script and placed onto an initial container. A subsequent container is then created, and the previously placed script is used as that new container's entrypoint. The logs for the container are forwarded to the underlying io.Writer.