container

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelManaged    = "cr.managed"
	LabelProjectDir = "cr.project_dir"
)

Variables

This section is empty.

Functions

func CheckNetworkConsistency added in v0.12.0

func CheckNetworkConsistency(ctx context.Context, dockerCLI command.Cli, allowExternal bool, projectNetwork string) error

CheckNetworkConsistency inspects projectNetwork and refuses attachment when it would leak egress. A blank projectNetwork is a no-op (nil).

func DetectProjectNetwork

func DetectProjectNetwork(ctx context.Context, dockerCLI command.Cli, suffix string) string

DetectProjectNetwork checks whether a Docker network named "<cwd-project>_<suffix>" exists. Returns the full network name if found, "" otherwise. If suffix is empty, "default" is used.

func DownProject

func DownProject(ctx context.Context, dockerCLI command.Cli, workingDir string) error

DownProject stops and removes a sandbox by its project working directory, without needing a full spec.

func NormalizeProjectName

func NormalizeProjectName(name string) string

NormalizeProjectName converts a directory name to a Docker Compose project name.

func ProjectSandboxName

func ProjectSandboxName(cwd string) string

Types

type CleanResult

type CleanResult struct {
	Containers int
	Networks   int
}

CleanResult reports how many containers and networks a prune removed.

type ContainerExecutor added in v0.12.0

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

ContainerExecutor manages one sandbox container through the Docker SDK.

func NewContainerExecutor added in v0.12.0

func NewContainerExecutor(dockerCLI command.Cli, spec *SandboxSpec) *ContainerExecutor

func (*ContainerExecutor) CleanStale added in v0.12.0

func (e *ContainerExecutor) CleanStale(ctx context.Context) (CleanResult, error)

CleanStale removes all agent-sandbox managed containers and cr-sandbox- networks.

func (*ContainerExecutor) Down added in v0.12.0

func (e *ContainerExecutor) Down(ctx context.Context) error

Down stops and removes the sandbox container and its network. The external project network is never touched.

func (*ContainerExecutor) IsRunning added in v0.12.0

func (e *ContainerExecutor) IsRunning(ctx context.Context) (bool, error)

IsRunning reports whether this project's sandbox container is running.

func (*ContainerExecutor) RunContainer added in v0.12.0

func (e *ContainerExecutor) RunContainer(ctx context.Context, argv []string, env []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)

RunContainer execs argv inside the running sandbox container, streaming stdout/stderr and optionally forwarding stdin, and returns the process exit code. It returns router.ErrSandboxNotRunning if the sandbox container is not currently running.

func (*ContainerExecutor) StartBackground added in v0.12.0

func (e *ContainerExecutor) StartBackground(ctx context.Context)

StartBackground runs Up in a goroutine; call WaitReady before issuing commands.

func (*ContainerExecutor) Up added in v0.12.0

Up runs the fail-closed consistency check, then ensures the image, sandbox network, and container exist, connects the project network (if any), and starts the container. It is idempotent: calling Up again on an already running sandbox succeeds without error.

func (*ContainerExecutor) WaitReady added in v0.12.0

func (e *ContainerExecutor) WaitReady(ctx context.Context) error

WaitReady blocks until StartBackground completes or ctx is cancelled.

type SandboxSpec added in v0.12.0

type SandboxSpec struct {
	Name            string
	WorkingDir      string
	ImageTag        string
	BuildContext    string
	Dockerfile      string
	NetworkName     string
	ExternalNetwork string
	UID             int
	GID             int
	Internal        bool
	Labels          map[string]string
}

SandboxSpec fully describes the single sandbox container to create.

func NewSandboxSpec added in v0.12.0

func NewSandboxSpec(uid, gid int, buildContext, dockerfile, image string, allowExternal bool, externalNetwork string) (*SandboxSpec, error)

NewSandboxSpec derives the container spec from config for the current directory.

Jump to

Keyboard shortcuts

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