docker

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package docker wraps the Docker API client for devrig container lifecycle management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecReadyCheck

func ExecReadyCheck(ctx context.Context, cli *dockerclient.Client, containerID, command string, expect *string) error

ExecReadyCheck runs a command-based ready check via docker exec.

func RunReadyCheck

func RunReadyCheck(
	ctx context.Context,
	cli *dockerclient.Client,
	containerID string,
	check *config.ReadyCheck,
	hostPort *uint16,
	name string,
) error

RunReadyCheck polls until the container passes its ready check or the configured timeout expires.

func StreamContainerLogs

func StreamContainerLogs(ctx context.Context, cli *dockerclient.Client, containerID, serviceName string, b *events.Broadcaster)

StreamContainerLogs subscribes to container logs and broadcasts each line as a KindLogRecord event until ctx is cancelled or the stream ends.

Types

type Manager

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

Manager manages Docker containers and networks for a devrig project.

func New

func New(slug string) (*Manager, error)

New creates a Manager and verifies Docker daemon connectivity.

func (*Manager) CleanupAll

func (m *Manager) CleanupAll(ctx context.Context) error

CleanupAll removes all containers, volumes, and the network for this project.

func (*Manager) Client

func (m *Manager) Client() *dockerclient.Client

func (*Manager) ConnectContainerToNetwork

func (m *Manager) ConnectContainerToNetwork(ctx context.Context, containerID string, aliases []string) error

ConnectContainerToNetwork connects a container to the project network with aliases.

func (*Manager) DeleteService

func (m *Manager) DeleteService(ctx context.Context, st *state.DockerState) error

DeleteService stops and removes a container.

func (*Manager) EnsureNetwork

func (m *Manager) EnsureNetwork(ctx context.Context) error

EnsureNetwork creates the project bridge network if it doesn't already exist.

func (*Manager) NetworkName

func (m *Manager) NetworkName() string

func (*Manager) RemoveNetwork

func (m *Manager) RemoveNetwork(ctx context.Context) error

RemoveNetwork removes the project network (ignores not-found). Any containers still attached (e.g. k3d cluster nodes) are force-disconnected first so the removal isn't blocked by an "active endpoints" error.

func (*Manager) Slug

func (m *Manager) Slug() string

func (*Manager) StartService

func (m *Manager) StartService(
	ctx context.Context,
	name string,
	cfg *config.DockerConfig,
	prevState *state.DockerState,
	allocated map[uint16]bool,
	configDir string,
) (state.DockerState, error)

StartService starts a single docker service container.

func (*Manager) StopService

func (m *Manager) StopService(ctx context.Context, st *state.DockerState) error

StopService stops a container (does not remove it).

type ReapResult added in v0.38.4

type ReapResult struct {
	Containers []string
	Volumes    []string
	Networks   []string
}

ReapResult lists the devrig-managed Docker resources removed by ReapOrphans.

func ReapOrphans added in v0.38.4

func ReapOrphans(ctx context.Context) (ReapResult, error)

ReapOrphans removes every devrig-managed Docker resource across all projects — containers, volumes, and networks identified by the devrig.managed-by label — regardless of slug. It backstops `devrig delete --all`, cleaning up resources left behind by an instance that was never registered (e.g. a start Ctrl-C'd mid-bringup) or whose state was already removed. Best-effort: individual removal failures are skipped rather than failing the whole sweep.

Jump to

Keyboard shortcuts

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