podman

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package podman provides a client wrapper for interacting with Podman.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides methods for interacting with Podman.

func NewClient

func NewClient(socketPath string, logger *slog.Logger) *Client

NewClient creates a new Podman client.

func (*Client) Exec

func (c *Client) Exec(containerName string, command []string) *exec.Cmd

Exec prepares a podman exec command.

func (*Client) ImageExists

func (c *Client) ImageExists(ctx context.Context, image string) (bool, error)

ImageExists checks if an image exists locally.

func (*Client) ListDanglingImages

func (c *Client) ListDanglingImages(ctx context.Context) ([]ImageInfo, error)

ListDanglingImages returns images that are not tagged.

func (*Client) ListImages

func (c *Client) ListImages(ctx context.Context) ([]ImageInfo, error)

ListImages returns all images.

func (*Client) ListStoppedContainers

func (c *Client) ListStoppedContainers(ctx context.Context) ([]ContainerInfo, error)

ListStoppedContainers returns all stopped containers.

func (*Client) Load

func (c *Client) Load(ctx context.Context, archivePath string) (string, error)

Load loads an image from a tar archive.

func (*Client) PruneContainers

func (c *Client) PruneContainers(ctx context.Context) (int, error)

PruneContainers removes all stopped containers.

func (*Client) PruneImages

func (c *Client) PruneImages(ctx context.Context) (int, error)

PruneImages removes unused images.

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, image string) error

Pull pulls an image from a registry.

func (*Client) Push

func (c *Client) Push(ctx context.Context, image string) error

Push pushes an image to a registry.

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(ctx context.Context, idOrName string) error

RemoveContainer removes a container by ID or name.

func (*Client) RemoveImage

func (c *Client) RemoveImage(ctx context.Context, image string) error

RemoveImage removes an image.

func (*Client) Run

Run creates and runs a container, waiting for it to complete. Returns the container result including exit code and output.

func (*Client) RunWithStreaming

func (c *Client) RunWithStreaming(ctx context.Context, cfg *ContainerConfig, stdout, stderr io.Writer) (*ContainerResult, error)

RunWithStreaming creates and runs a container, streaming output to the provided writers.

func (*Client) Tag

func (c *Client) Tag(ctx context.Context, source, target string) error

Tag tags an image with a new name.

type ContainerConfig

type ContainerConfig struct {
	Name        string
	Image       string
	Entrypoint  []string // Override container entrypoint
	Command     []string
	WorkDir     string
	Env         map[string]string
	Mounts      []Mount
	Limits      *ResourceLimits
	User        string
	NetworkMode string
	Remove      bool   // Remove container after exit
	Privileged  bool   // Run container in privileged mode
	UserNS      string // User namespace mode (e.g., "keep-id", "host")
}

ContainerConfig holds configuration for creating a container.

type ContainerInfo

type ContainerInfo struct {
	ID        string
	Name      string
	Image     string
	Status    string
	CreatedAt time.Time
	StoppedAt time.Time
}

ContainerInfo holds information about a container.

type ContainerResult

type ContainerResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Duration time.Duration
}

ContainerResult holds the result of a container execution.

type ImageInfo

type ImageInfo struct {
	ID        string
	Tags      []string
	Size      int64
	CreatedAt time.Time
}

ImageInfo holds information about an image.

type Mount

type Mount struct {
	Source   string
	Target   string
	ReadOnly bool
}

Mount defines a bind mount for a container.

type ResourceLimits

type ResourceLimits struct {
	CPUQuota  float64 // CPU quota in cores (e.g., 0.5 = half a core)
	MemoryMB  int64   // Memory limit in megabytes
	PidsLimit int64   // Maximum number of PIDs
}

ResourceLimits defines resource constraints for a container.

func ResourceLimitsFromSpec

func ResourceLimitsFromSpec(spec *models.ResourceSpec) *ResourceLimits

ResourceLimitsFromSpec returns resource limits from a ResourceSpec. If spec is nil, returns default limits (0.5 CPU, 512MB).

Jump to

Keyboard shortcuts

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