Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPort(port int) bool
- func CheckVMNetwork() error
- func ConfigHash(cfg string) string
- func CopyTo(containerName, hostPath, containerPath string) error
- func Create(args ...string) error
- func EnsurePodman() error
- func Exec(containerName string, cmdAndArgs ...string) error
- func ExecOutput(containerName string, cmdAndArgs ...string) (string, error)
- func FilterEnv(env []string, keys ...string) []string
- func FollowLogs(ctx context.Context, containerName string) error
- func GetPidOnPort(port int) (int, error)
- func InspectLabel(containerName, label string) string
- func InspectStatus(containerName string) (string, error)
- func KillPortPid(port int) (int, error)
- func OnSignal(fn func()) (cancel func())
- func PodmanArch() (string, error)
- func Remove(containerName string, force bool) error
- func Run(name string, args ...string) error
- func Start(containerName string) error
- func Stop(containerName string) error
Constants ¶
const DefaultNetworkCheckTimeout = 15 * time.Second
Variables ¶
var ErrNoProcessOnPort = errors.New("no process found on port")
ErrNoProcessOnPort is returned when no process is found listening on a port.
Functions ¶
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 ¶
ConfigHash returns the first 8 hex chars of the SHA-256 hash of cfg.
func Create ¶
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 ExecOutput ¶
ExecOutput executes a command inside a running container and returns stdout.
func FilterEnv ¶
FilterEnv returns env with the specified keys removed. Each key is matched as a prefix followed by "=".
func FollowLogs ¶
FollowLogs streams container logs to stdout/stderr until the context is cancelled or the container exits.
func GetPidOnPort ¶
GetPidOnPort returns the PID of the process listening on the given TCP port. Returns ErrNoProcessOnPort if no process is found.
func InspectLabel ¶
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 ¶
InspectStatus returns the running status of the named container (e.g. "running", "stopped"). Returns an error if the container does not exist.
func KillPortPid ¶
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 ¶
PodmanArch returns the architecture of the podman VM (e.g. "amd64", "arm64").
func Remove ¶
Remove stops and removes a container. If force is true, uses -f. Returns silently if the container does not exist.
Types ¶
This section is empty.