docker

package
v0.0.0-...-094827e Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerConfig

type ContainerConfig struct {
	Name       string
	ImageURI   string
	Entrypoint []string
	Command    []string
	WorkingDir string
	Env        []string
	Binds      []string
	// Networks is a list of network IDs the container should be connected to.
	// The container will always be connected to the host network by default.
	Networks []string
	// Aliases is a list of names this container will be resolvable on from
	// each of the configured networks (if any).
	Aliases []string
	Stdout  io.Writer
	Stderr  io.Writer
}

type ContainerManager

type ContainerManager struct {
	// contains filtered or unexported fields
}

func NewContainerManager

func NewContainerManager(syslog *zap.SugaredLogger, client *client.Client) *ContainerManager

func (*ContainerManager) CreateNetwork

func (r *ContainerManager) CreateNetwork(ctx context.Context, name string) (string, error)

CreateNetwork creates a new private network and returns its ID.

func (*ContainerManager) DeleteNetwork

func (r *ContainerManager) DeleteNetwork(ctx context.Context, networkID string) error

DeleteNetwork deletes a previously created network.

func (*ContainerManager) Execute

func (r *ContainerManager) Execute(ctx context.Context, config ExecConfig) error

Execute a command inside the container. StartContainer must have previously been called.

func (*ContainerManager) GetDockerImageOS

func (r *ContainerManager) GetDockerImageOS(ctx context.Context, imageURI string) (runtime.OS, error)

GetDockerImageOS returns the type of underlying guest OS the specified Docker image is made from. The docker image must have been pulled first.

func (*ContainerManager) PullDockerImage

func (r *ContainerManager) PullDockerImage(ctx context.Context, log *runtime.Log, opts *executorv1.DockerPullOpts) error

PullDockerImage pulls a Docker Image from a remote registry.

func (*ContainerManager) StartContainer

func (r *ContainerManager) StartContainer(ctx context.Context, config ContainerConfig) (string, error)

StartContainer starts a new container in the background and returns its unique ID. Call StopContainer to stop it and free up resources.

func (*ContainerManager) StopContainer

func (r *ContainerManager) StopContainer(ctx context.Context, containerID string) error

StopContainer stops and removes a previously started docker container.

type DockerPullStrategy

type DockerPullStrategy string
const (
	DockerPullStrategyDefault     DockerPullStrategy = "default"
	DockerPullStrategyNever       DockerPullStrategy = "never"
	DockerPullStrategyAlways      DockerPullStrategy = "always"
	DockerPullStrategyIfNotExists DockerPullStrategy = "if-not-exists"
)

func (*DockerPullStrategy) Scan

func (m *DockerPullStrategy) Scan(src interface{}) error

func (DockerPullStrategy) String

func (m DockerPullStrategy) String() string

func (DockerPullStrategy) Valid

func (m DockerPullStrategy) Valid() bool

type ExecConfig

type ExecConfig struct {
	ContainerID string
	Command     []string
	WorkingDir  string
	Env         []string
	Stdout      io.Writer
	Stderr      io.Writer
}

type Runtime

type Runtime struct {
	file.WriteFS
	// contains filtered or unexported fields
}

Runtime executes jobs inside a Docker container.

func NewRuntime

func NewRuntime(syslog *zap.SugaredLogger, log *runtime.Log, runtimeID string, opts *executorv1.DockerOpts, client *client.Client) (*Runtime, error)

func (*Runtime) Close

func (r *Runtime) Close() error

Close tears down the runtime.

func (*Runtime) Deadline

func (r *Runtime) Deadline() time.Time

func (*Runtime) Directory

func (r *Runtime) Directory() string

func (*Runtime) Exec

func (r *Runtime) Exec(ctx context.Context, execID string, opts *executorv1.ExecOpts) (*runtime.ExecResult, error)

Exec executes a command inside the runtime. Start must have been called before calling Exec.

func (*Runtime) ID

func (r *Runtime) ID() string

func (*Runtime) Log

func (r *Runtime) Log() *runtime.Log

func (*Runtime) SetDeadline

func (r *Runtime) SetDeadline(deadline time.Time)

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context) error

Start initializes the runtime and prepares it to have commands Exec'd inside it.

Jump to

Keyboard shortcuts

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