docker

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package docker provides Docker-specific implementation of container runtime, including creating, starting, stopping, and monitoring containers.

Index

Constants

View Source
const (
	ToolhiveAuxiliaryWorkloadLabel = "toolhive-auxiliary-workload"
	LabelValueTrue                 = "true"
)

Workloads

View Source
const DnsImage = "dockurr/dnsmasq:latest"

DnsImage is the default DNS image used for network permissions

View Source
const RuntimeName = "docker"

RuntimeName is the name identifier for the Docker runtime

Variables

View Source
var (
	// ErrMultipleContainersFound is returned when multiple containers are found
	ErrMultipleContainersFound = httperr.WithCode(fmt.Errorf("multiple containers found with same name"), http.StatusBadRequest)

	// ErrAttachFailed is returned when attaching to a container fails
	ErrAttachFailed = httperr.WithCode(fmt.Errorf("failed to attach to container"), http.StatusBadRequest)
)

Docker-specific error types

View Source
var (
	// Deprecated: Use runtime.ErrContainerNotFound.
	ErrContainerNotFound = runtime.ErrContainerNotFound

	// Deprecated: Use runtime.ErrContainerNotRunning.
	ErrContainerNotRunning = runtime.ErrContainerNotRunning

	// Deprecated: Use runtime.ErrContainerExited.
	ErrContainerExited = runtime.ErrContainerExited

	// Deprecated: Use runtime.ErrContainerRestarted.
	ErrContainerRestarted = runtime.ErrContainerRestarted

	// Deprecated: Use runtime.ErrContainerRemoved.
	ErrContainerRemoved = runtime.ErrContainerRemoved

	// Deprecated: Use runtime.NewContainerError.
	NewContainerError = runtime.NewContainerError

	// Deprecated: Use runtime.IsContainerNotFound.
	IsContainerNotFound = runtime.IsContainerNotFound
)

Deprecated aliases — kept so that docker/client.go compiles without changes. New code should use the runtime package directly.

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

Types

type Client

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

Client implements the Deployer interface for Docker (and compatible runtimes)

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new container client

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, lines int) (string, error)

GetWorkloadLogs gets workload logs

func (*Client) IsRunning added in v0.1.1

func (c *Client) IsRunning(ctx context.Context) error

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

func (c *Client) IsWorkloadRunning(ctx context.Context, workloadName string) (bool, error)

IsWorkloadRunning checks if a workload is running

func (*Client) ListWorkloads added in v0.0.37

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

ListWorkloads lists workloads

func (*Client) RemoveWorkload added in v0.0.37

func (c *Client) RemoveWorkload(ctx context.Context, workloadName string) error

RemoveWorkload removes a workload If the workload doesn't exist, it returns success

func (*Client) StopWorkload added in v0.0.37

func (c *Client) StopWorkload(ctx context.Context, workloadName string) error

StopWorkload stops a workload If the workload is already stopped, it returns success

type ContainerError deprecated

type ContainerError = runtime.ContainerError

ContainerError is a deprecated alias for runtime.ContainerError.

Deprecated: Use runtime.ContainerError.

Directories

Path Synopsis
Package sdk provides a factory method for creating a Docker client.
Package sdk provides a factory method for creating a Docker client.

Jump to

Keyboard shortcuts

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