docker

package
v0.2.27 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps Docker API operations

func NewClient

func NewClient(socketPath string) (*Client, error)

NewClient creates a new Docker client

func (*Client) Close

func (c *Client) Close() error

Close closes the Docker client and all its connections

func (*Client) CreateExec added in v0.1.0

func (c *Client) CreateExec(ctx context.Context, config *ExecConfig) (*ExecCreateResponse, error)

CreateExec creates a new exec instance in a container

func (*Client) GetDataRoot

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

GetDataRoot returns Docker's data root directory

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context) (*VersionInfo, error)

GetVersion returns Docker version information

func (*Client) Ping

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

Ping checks Docker daemon connectivity

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, headers map[string]string, body io.Reader) (*http.Response, error)

Request makes an HTTP request to the Docker API

func (*Client) RequestRaw

func (c *Client) RequestRaw(ctx context.Context, method, path string, headers map[string]string, body io.Reader) (*http.Response, error)

RequestRaw makes a request without API versioning (for proxying)

func (*Client) ResizeExec added in v0.1.0

func (c *Client) ResizeExec(ctx context.Context, execID string, height, width int) error

ResizeExec resizes the exec terminal

func (*Client) StartExecAttach added in v0.1.0

func (c *Client) StartExecAttach(ctx context.Context, execID string) (*HijackedConn, error)

StartExecAttach starts an exec instance and returns a hijacked connection

func (*Client) StreamRequest

func (c *Client) StreamRequest(ctx context.Context, method, path string, headers map[string]string, body io.Reader) (*http.Response, error)

StreamRequest makes a streaming request (for logs, exec, events) Uses the pre-initialized streamClient which has no timeout and proper connection pooling

type ComposeClient

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

ComposeClient handles Docker Compose operations

func NewComposeClient

func NewComposeClient(dockerSocket, stacksDir string) *ComposeClient

NewComposeClient creates a new Compose client

func (*ComposeClient) Execute

Execute runs a Docker Compose operation

func (*ComposeClient) GetVersion

func (c *ComposeClient) GetVersion() (string, error)

GetVersion returns docker compose version

func (*ComposeClient) IsAvailable

func (c *ComposeClient) IsAvailable() bool

IsAvailable checks if docker compose is available

func (*ComposeClient) SetAPIVersion added in v0.2.12

func (c *ComposeClient) SetAPIVersion(version string)

SetAPIVersion sets the Docker API version to use for compose commands. This enables compatibility when the docker CLI version differs from the daemon.

type ComposeOperation

type ComposeOperation struct {
	Operation       string                `json:"operation"` // up, down, pull, ps, logs
	ProjectName     string                `json:"projectName"`
	WorkDir         string                `json:"workDir"`
	ComposeFile     string                `json:"composeFile,omitempty"`     // Content of compose file
	ComposeFileName string                `json:"composeFileName,omitempty"` // Explicit compose filename to use (e.g., "docker-compose.prod.yml")
	Files           map[string]string     `json:"files,omitempty"`           // All files to write (relative path -> content)
	Services        []string              `json:"services,omitempty"`        // Specific services to operate on
	Options         map[string]string     `json:"options,omitempty"`         // Additional options
	EnvVars         map[string]string     `json:"envVars,omitempty"`         // Environment variables for variable substitution
	Registries      []RegistryCredentials `json:"registries,omitempty"`      // Registry credentials for docker login
	ForceRecreate   bool                  `json:"forceRecreate,omitempty"`   // Force recreation of containers (--force-recreate)
	RemoveVolumes   bool                  `json:"removeVolumes,omitempty"`   // Remove volumes on down (--volumes)
	ServiceName     string                `json:"serviceName,omitempty"`     // Target specific service only (with --no-deps)
	Build           bool                  `json:"build,omitempty"`           // Build images before starting (--build)
}

ComposeOperation represents a compose operation request

type ComposeResult

type ComposeResult struct {
	Success  bool   `json:"success"`
	Output   string `json:"output"`
	Error    string `json:"error,omitempty"`
	ExitCode int    `json:"exitCode"`
}

ComposeResult is the result of a compose operation

type ComposeService

type ComposeService struct {
	ID         string   `json:"ID"`
	Name       string   `json:"Name"`
	Service    string   `json:"Service"`
	State      string   `json:"State"`
	Status     string   `json:"Status"`
	Health     string   `json:"Health,omitempty"`
	Image      string   `json:"Image"`
	Publishers []string `json:"Publishers,omitempty"`
}

ComposeService represents a service from docker compose ps

func ParseComposePS

func ParseComposePS(output string) ([]ComposeService, error)

ParseComposePS parses the JSON output of docker compose ps

type ExecConfig added in v0.1.0

type ExecConfig struct {
	ContainerID string
	Cmd         []string
	User        string
	Tty         bool
}

ExecConfig holds the configuration for creating an exec instance

type ExecCreateResponse added in v0.1.0

type ExecCreateResponse struct {
	ID string `json:"Id"`
}

ExecCreateResponse is the response from exec create

type HijackedConn added in v0.1.0

type HijackedConn struct {
	Conn     net.Conn
	Reader   *io.Reader
	Leftover []byte // Any data read past the HTTP headers
}

HijackedConn represents a hijacked connection for exec

type RegistryCredentials added in v0.2.17

type RegistryCredentials struct {
	URL      string `json:"url"`
	Username string `json:"username"`
	Password string `json:"password"`
}

RegistryCredentials holds credentials for a Docker registry

type VersionInfo

type VersionInfo struct {
	Version       string `json:"Version"`
	APIVersion    string `json:"ApiVersion"`
	MinAPIVersion string `json:"MinAPIVersion"`
	GitCommit     string `json:"GitCommit"`
	GoVersion     string `json:"GoVersion"`
	Os            string `json:"Os"`
	Arch          string `json:"Arch"`
	KernelVersion string `json:"KernelVersion"`
	BuildTime     string `json:"BuildTime"`
}

VersionInfo contains Docker version information

Jump to

Keyboard shortcuts

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