Documentation
¶
Overview ¶
Package runtime provides a container runtime abstraction for Docker and Podman. Both runtimes share a compatible CLI interface, so a single implementation handles both via os/exec.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BuildOptions ¶ added in v0.0.4
type BuildOptions struct {
// Tag is the image tag to build.
Tag string
// Dockerfile is the path to the Dockerfile.
Dockerfile string
// Context is the build context directory.
Context string
}
BuildOptions configures an image build invocation.
type ContainerInfo ¶
type ContainerInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
Status string `json:"status"`
StartedAt time.Time `json:"startedAt"`
}
ContainerInfo holds information about a running container.
type RunOptions ¶
type RunOptions struct {
// Name is the container name.
Name string
// Image is the container image reference.
Image string
// Detach runs the container in background.
Detach bool
// User overrides the container user (e.g. "1000:1000").
// This is essential for bind mounts so the container process matches
// the host UID that owns the mounted files.
User string
// EnvVars are environment variables to set.
EnvVars map[string]string
// Volumes are bind mount specifications.
Volumes []Volume
// Ports maps host ports to container ports.
Ports map[int]int
}
RunOptions configures a container run invocation.
type Runtime ¶
type Runtime interface {
// Name returns the runtime name ("docker" or "podman").
Name() string
// Run starts a new container and returns its ID.
Run(ctx context.Context, opts RunOptions) (string, error)
// Stop stops a running container.
Stop(ctx context.Context, name string) error
// Remove removes a container.
Remove(ctx context.Context, name string) error
// Status returns the container status ("running", "exited", "created", etc.)
// or an empty string if the container doesn't exist.
Status(ctx context.Context, name string) (string, error)
// Inspect returns detailed container information.
Inspect(ctx context.Context, name string) (*ContainerInfo, error)
// Logs streams container logs to stdout/stderr. If follow is true, it
// streams continuously until interrupted. If tail > 0, only the last N
// lines are shown.
Logs(ctx context.Context, name string, follow bool, tail int) error
// BuildImage builds a container image from a Dockerfile.
// Returns the image tag on success.
BuildImage(ctx context.Context, opts BuildOptions) (string, error)
// ImageExists checks if an image tag exists locally.
ImageExists(ctx context.Context, tag string) (bool, error)
}
Runtime is the interface for managing container lifecycle operations.
Click to show internal directories.
Click to hide internal directories.