Documentation
¶
Overview ¶
Package docker wraps the Docker API client for devrig container lifecycle management.
Index ¶
- func ExecReadyCheck(ctx context.Context, cli *dockerclient.Client, containerID, command string, ...) error
- func RunReadyCheck(ctx context.Context, cli *dockerclient.Client, containerID string, ...) error
- func StreamContainerLogs(ctx context.Context, cli *dockerclient.Client, containerID, serviceName string, ...)
- type Manager
- func (m *Manager) CleanupAll(ctx context.Context) error
- func (m *Manager) Client() *dockerclient.Client
- func (m *Manager) ConnectContainerToNetwork(ctx context.Context, containerID string, aliases []string) error
- func (m *Manager) DeleteService(ctx context.Context, st *state.DockerState) error
- func (m *Manager) EnsureNetwork(ctx context.Context) error
- func (m *Manager) NetworkName() string
- func (m *Manager) RemoveNetwork(ctx context.Context) error
- func (m *Manager) Slug() string
- func (m *Manager) StartService(ctx context.Context, name string, cfg *config.DockerConfig, ...) (state.DockerState, error)
- func (m *Manager) StopService(ctx context.Context, st *state.DockerState) error
- type ReapResult
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 (*Manager) CleanupAll ¶
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 ¶
DeleteService stops and removes a container.
func (*Manager) EnsureNetwork ¶
EnsureNetwork creates the project bridge network if it doesn't already exist.
func (*Manager) NetworkName ¶
func (*Manager) RemoveNetwork ¶
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) 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 ¶
StopService stops a container (does not remove it).
type ReapResult ¶ added in v0.38.4
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.