exec

package
v0.0.0-...-c00219f Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package exec provides internal utilities for executing container CLI commands.

Package exec provides internal utilities for executing container CLI commands.

Index

Constants

View Source
const (
	StatusRunning = "running"
	StatusStopped = "stopped"
)

Variables

View Source
var ErrEmptyInspect = errors.New("empty inspect result")

ErrEmptyInspect is returned when container inspect returns an empty result, indicating the container is not yet visible to the daemon.

Functions

func Exec

func Exec(ctx context.Context, id string, args ...string) error

Exec runs a command inside a running container and returns an error if it fails.

func ForceRemove

func ForceRemove(ctx context.Context, id string) error

ForceRemove kills and removes a container. It is idempotent: if the container is already removed, it returns nil.

func IsContainerNotFound

func IsContainerNotFound(err error) bool

IsContainerNotFound checks if an error represents a "container not found" condition.

func IsDeleteAlreadyDone

func IsDeleteAlreadyDone(err error) bool

IsDeleteAlreadyDone checks if a delete error indicates the container was already deleted (e.g., "failed to delete one or more containers").

func Logs

func Logs(ctx context.Context, id string) (string, error)

func StreamLogs

func StreamLogs(ctx context.Context, id string) (io.ReadCloser, error)

Types

type CliError

type CliError struct {
	Stderr string
}

func (*CliError) Error

func (e *CliError) Error() string

type ContainerInfo

type ContainerInfo struct {
	Configuration struct {
		ID             string            `json:"id"`
		Labels         map[string]string `json:"labels"`
		PublishedPorts []PublishedPort   `json:"publishedPorts"`
	} `json:"configuration"`
	Status string `json:"status"` // "running" or "stopped"
}

func Inspect

func Inspect(ctx context.Context, id string) (*ContainerInfo, error)

func List

func List(ctx context.Context) ([]*ContainerInfo, error)

type ContainerRawOutput

type ContainerRawOutput struct {
	ID string
}

func Run

func Run(ctx context.Context, args ...string) (*ContainerRawOutput, error)

type PublishedPort

type PublishedPort struct {
	HostPort      int    `json:"hostPort"`
	ContainerPort int    `json:"containerPort"`
	HostAddress   string `json:"hostAddress"`
	Proto         string `json:"proto"`
}

Jump to

Keyboard shortcuts

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