Documentation
¶
Overview ¶
Package docker provides Docker-specific implementation of container runtime, including creating, starting, stopping, and monitoring containers.
Index ¶
- Constants
- Variables
- func IsAvailable() bool
- func IsContainerNotFound(err error) bool
- func NewMonitor(rt runtime.Runtime, containerName string) runtime.Monitor
- type Client
- func (c *Client) AttachToWorkload(ctx context.Context, workloadName string) (io.WriteCloser, io.ReadCloser, error)
- func (c *Client) DeployWorkload(ctx context.Context, image, name string, command []string, ...) (int, error)
- func (c *Client) GetWorkloadInfo(ctx context.Context, workloadName string) (runtime.ContainerInfo, error)
- func (c *Client) GetWorkloadLogs(ctx context.Context, workloadName string, follow bool) (string, error)
- func (c *Client) IsRunning(ctx context.Context) error
- func (c *Client) IsWorkloadRunning(ctx context.Context, workloadName string) (bool, error)
- func (c *Client) ListWorkloads(ctx context.Context) ([]runtime.ContainerInfo, error)
- func (c *Client) RemoveWorkload(ctx context.Context, workloadName string) error
- func (c *Client) StopWorkload(ctx context.Context, workloadName string) error
- type ContainerError
- type ContainerMonitor
Constants ¶
const ( ToolhiveAuxiliaryWorkloadLabel = "toolhive-auxiliary-workload" LabelValueTrue = "true" )
Workloads
const DnsImage = "dockurr/dnsmasq:latest"
DnsImage is the default DNS image used for network permissions
const RuntimeName = "docker"
RuntimeName is the name identifier for the Docker runtime
Variables ¶
var ( // ErrContainerNotFound is returned when a container is not found ErrContainerNotFound = fmt.Errorf("container not found") // ErrMultipleContainersFound is returned when multiple containers are found ErrMultipleContainersFound = fmt.Errorf("multiple containers found with same name") // ErrContainerNotRunning is returned when a container is not running ErrContainerNotRunning = fmt.Errorf("container not running") // ErrAttachFailed is returned when attaching to a container fails ErrAttachFailed = fmt.Errorf("failed to attach to container") // ErrContainerExited is returned when a container has exited unexpectedly ErrContainerExited = fmt.Errorf("container exited unexpectedly") )
Error types for container operations
Functions ¶
func IsAvailable ¶ added in v0.2.11
func IsAvailable() bool
IsAvailable checks if Docker is available by attempting to connect to the Docker daemon
func IsContainerNotFound ¶
IsContainerNotFound checks if the error is a container not found error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the Deployer interface for Docker (and compatible runtimes)
func (*Client) AttachToWorkload ¶ added in v0.0.37
func (c *Client) AttachToWorkload(ctx context.Context, workloadName string) (io.WriteCloser, io.ReadCloser, error)
AttachToWorkload attaches to a workload
func (*Client) DeployWorkload ¶ added in v0.0.37
func (c *Client) DeployWorkload( ctx context.Context, image, name string, command []string, envVars, labels map[string]string, permissionProfile *permissions.Profile, transportType string, options *runtime.DeployWorkloadOptions, isolateNetwork bool, ) (int, error)
DeployWorkload creates and starts a workload. It configures the workload based on the provided permission profile and transport type. If options is nil, default options will be used.
func (*Client) GetWorkloadInfo ¶ added in v0.0.37
func (c *Client) GetWorkloadInfo(ctx context.Context, workloadName string) (runtime.ContainerInfo, error)
GetWorkloadInfo gets workload information
func (*Client) GetWorkloadLogs ¶ added in v0.0.37
func (c *Client) GetWorkloadLogs(ctx context.Context, workloadName string, follow bool) (string, error)
GetWorkloadLogs gets workload logs
func (*Client) IsRunning ¶ added in v0.1.1
IsRunning checks the health of the container runtime. This is used to verify that the runtime is operational and can manage workloads.
func (*Client) IsWorkloadRunning ¶ added in v0.0.37
IsWorkloadRunning checks if a workload is running
func (*Client) ListWorkloads ¶ added in v0.0.37
ListWorkloads lists workloads
func (*Client) RemoveWorkload ¶ added in v0.0.37
RemoveWorkload removes a workload If the workload doesn't exist, it returns success
type ContainerError ¶
type ContainerError struct { // Err is the underlying error Err error // ContainerID is the ID of the container ContainerID string // Message is an optional error message Message string }
ContainerError represents an error related to container operations
func NewContainerError ¶
func NewContainerError(err error, containerID, message string) *ContainerError
NewContainerError creates a new container error
func (*ContainerError) Error ¶
func (e *ContainerError) Error() string
Error returns the error message
func (*ContainerError) Unwrap ¶
func (e *ContainerError) Unwrap() error
Unwrap returns the underlying error
type ContainerMonitor ¶
type ContainerMonitor struct {
// contains filtered or unexported fields
}
ContainerMonitor watches a container's state and reports when it exits
func (*ContainerMonitor) StartMonitoring ¶
func (m *ContainerMonitor) StartMonitoring(ctx context.Context) (<-chan error, error)
StartMonitoring starts monitoring the container
func (*ContainerMonitor) StopMonitoring ¶
func (m *ContainerMonitor) StopMonitoring()
StopMonitoring stops monitoring the container