podman

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultNetworkCheckTimeout = 15 * time.Second

Variables

View Source
var ErrNoProcessOnPort = errors.New("no process found on port")

ErrNoProcessOnPort is returned when no process is found listening on a port.

Functions

func CheckPort

func CheckPort(port int) bool

CheckPort returns true if the port is in use (someone is listening on it).

func CheckVMNetwork

func CheckVMNetwork() error

CheckVMNetwork verifies the podman VM can reach the internet. If not, it restarts the machine (a common fix for stale network bridges).

func ConfigHash

func ConfigHash(cfg string) string

ConfigHash returns the first 8 hex chars of the SHA-256 hash of cfg.

func CopyTo

func CopyTo(containerName, hostPath, containerPath string) error

CopyTo copies a file or directory from the host into the container.

func Create

func Create(args ...string) error

Create creates a new container with the given arguments. args should include all podman create arguments (e.g. "--name", "my-container", "image", ...).

func EnsurePodman

func EnsurePodman() error

EnsurePodman checks that podman is installed and the machine is running. It will init and start the podman machine if needed.

func Exec

func Exec(containerName string, cmdAndArgs ...string) error

Exec executes a command inside a running container with terminal I/O.

func ExecOutput

func ExecOutput(containerName string, cmdAndArgs ...string) (string, error)

ExecOutput executes a command inside a running container and returns stdout.

func FilterEnv

func FilterEnv(env []string, keys ...string) []string

FilterEnv returns env with the specified keys removed. Each key is matched as a prefix followed by "=".

func FollowLogs

func FollowLogs(ctx context.Context, containerName string) error

FollowLogs streams container logs to stdout/stderr until the context is cancelled or the container exits.

func GetPidOnPort

func GetPidOnPort(port int) (int, error)

GetPidOnPort returns the PID of the process listening on the given TCP port. Returns ErrNoProcessOnPort if no process is found.

func InspectLabel

func InspectLabel(containerName, label string) string

InspectLabel reads a label value from the container's config. Returns "" if the label is not set or the container does not exist.

func InspectStatus

func InspectStatus(containerName string) (string, error)

InspectStatus returns the running status of the named container (e.g. "running", "stopped"). Returns an error if the container does not exist.

func KillPortPid

func KillPortPid(port int) (int, error)

KillPortPid kills any process listening on the given port and waits for it to be free. Returns the killed PID, or 0 if no process was found.

func OnSignal

func OnSignal(fn func()) (cancel func())

OnSignal runs fn when SIGINT or SIGTERM is received. Returns a cancel function to stop listening.

func PodmanArch

func PodmanArch() (string, error)

PodmanArch returns the architecture of the podman VM (e.g. "amd64", "arm64").

func Remove

func Remove(containerName string, force bool) error

Remove stops and removes a container. If force is true, uses -f. Returns silently if the container does not exist.

func Run

func Run(name string, args ...string) error

Run executes a command with stdout/stderr connected to the terminal. Use this for long-running or verbose podman commands where output should be visible to the user.

func Start

func Start(containerName string) error

Start starts a stopped container.

func Stop

func Stop(containerName string) error

Stop stops a running container.

Types

This section is empty.

Jump to

Keyboard shortcuts

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