container

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverDocker = "docker"
	DriverPodman = "podman"
	DriverApple  = "apple"
)
View Source
const (
	LibraryName = "scriptling.container"
	LibraryDesc = "Container management library supporting Docker, Podman, and Apple Containers"

	DefaultDockerSocket = "/var/run/docker.sock"
	DefaultPodmanSocket = "/var/run/podman.sock"
)

Variables

This section is empty.

Functions

func Register

func Register(registrar interface{ RegisterLibrary(*object.Library) }, dockerSock, podmanSock string)

Register registers the scriptling.container library with the given registrar. dockerSock and podmanSock override the default socket paths (empty = use default).

Types

type ContainerDriver

type ContainerDriver interface {
	// Login authenticates with a container registry.
	Login(ctx context.Context, server, username, password string) error

	// Pull fetches an image from a registry.
	Pull(ctx context.Context, image string) error

	// Exec runs a command inside a running container and captures output.
	Exec(ctx context.Context, nameOrID string, command []string, opts ExecOptions) (*ExecResult, error)

	// ExecStream runs a command inside a running container, calling fn for each output line.
	ExecStream(ctx context.Context, nameOrID string, command []string, opts ExecOptions, fn func(stream, line string)) (*ExecResult, error)

	// ImageList returns locally available images.
	ImageList(ctx context.Context) ([]ImageInfo, error)

	// ImageRemove removes a local image.
	ImageRemove(ctx context.Context, image string) error

	// Run creates and starts a container, returning its ID.
	Run(ctx context.Context, image string, opts RunOptions) (string, error)

	// Stop stops a running container (graceful then force).
	Stop(ctx context.Context, nameOrID string) error

	// Remove removes a stopped container.
	Remove(ctx context.Context, nameOrID string) error

	// Inspect returns details about a container.
	Inspect(ctx context.Context, nameOrID string) (*ContainerInfo, error)

	// List returns all containers (running and stopped).
	List(ctx context.Context) ([]ContainerInfo, error)

	// VolumeCreate creates a named volume. size is optional (e.g. "20G") and
	// only honoured by Apple Containers; other drivers silently ignore it.
	VolumeCreate(ctx context.Context, name, size string) error

	// VolumeRemove removes a named volume.
	VolumeRemove(ctx context.Context, name string) error

	// VolumeList returns all named volumes.
	VolumeList(ctx context.Context) ([]string, error)
}

ContainerDriver is the interface every runtime driver must implement.

type ContainerInfo

type ContainerInfo struct {
	ID      string
	Name    string
	Status  string
	Image   string
	Running bool
}

ContainerInfo is the common container representation returned by inspect/list.

type ExecOptions

type ExecOptions struct {
	Env     []string
	WorkDir string
	User    string
}

ExecOptions holds optional parameters for Exec / ExecStream.

type ExecResult

type ExecResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

ExecResult holds the output of a completed exec.

type ImageInfo

type ImageInfo struct {
	ID        string
	Reference string
	Digest    string
	Size      int64
}

ImageInfo is the common image representation returned by image_list.

type RunOptions

type RunOptions struct {
	Name       string
	Ports      []string // "hostPort:containerPort"
	Env        []string // "KEY=value"
	Volumes    []string // "name:/path" or "/host:/container"
	Command    []string
	Privileged bool
	Network    string
}

RunOptions holds parameters for starting a container.

Jump to

Keyboard shortcuts

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