Documentation
¶
Overview ¶
Package container provides Docker container management for agentbox.
Index ¶
- func ImageName(imageType string) string
- func ParseCPUs(cpus string) (float64, error)
- func ParseMemory(mem string) (int64, error)
- func ProxyContainerName(baseName string) string
- func RestrictedNetworkName(baseName string) string
- func ValidateProjectPath(projectPath string) error
- type ContainerConfig
- type Manager
- func (m *Manager) Attach(ctx context.Context, containerID string) error
- func (m *Manager) Close() error
- func (m *Manager) Create(ctx context.Context, cfg *ContainerConfig) (string, error)
- func (m *Manager) CreateRestrictedNetwork(ctx context.Context, baseName string, agentImage string, allowedHosts []string) (*RestrictedNetwork, error)
- func (m *Manager) Logs(ctx context.Context, containerID string) (string, error)
- func (m *Manager) Remove(ctx context.Context, containerID string) error
- func (m *Manager) RemoveRestrictedNetwork(ctx context.Context, rn *RestrictedNetwork) error
- func (m *Manager) Run(ctx context.Context, cfg *ContainerConfig) (string, error)
- func (m *Manager) Stop(ctx context.Context, containerID string) error
- func (m *Manager) Wait(ctx context.Context, containerID string) (string, error)
- type RestrictedNetwork
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseMemory ¶
ParseMemory converts a memory string (e.g., "4g") to bytes.
func ProxyContainerName ¶
ProxyContainerName returns the deterministic name for the proxy sidecar.
func RestrictedNetworkName ¶
RestrictedNetworkName returns the deterministic name for the internal network.
func ValidateProjectPath ¶
ValidateProjectPath checks that the path is safe to mount.
Types ¶
type ContainerConfig ¶
type ContainerConfig struct {
Name string
Image string
WorkDir string
ProjectPath string
Env []string
Cmd []string
Network string
AllowedEndpoints []string // host:port pairs for restricted network mode
Memory int64
CPUs float64
MountSSH bool
MountGit bool
MountClaudeConfig bool
Interactive bool // allocate TTY and keep stdin open
}
ContainerConfig holds all settings for creating a container.
func ConfigToContainerConfig ¶
func ConfigToContainerConfig(cfg *config.Config, projectPath string, cmd []string, env []string) (*ContainerConfig, error)
ConfigToContainerConfig converts an agentbox config to container config.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles Docker container lifecycle.
func NewManager ¶
NewManager creates a new Docker container manager.
func (*Manager) Close ¶
Close cleans up any remaining restricted networks and releases the Docker client resources. This is a safety net for networks not cleaned up by Remove (e.g., if the process was interrupted).
func (*Manager) CreateRestrictedNetwork ¶
func (m *Manager) CreateRestrictedNetwork(ctx context.Context, baseName string, agentImage string, allowedHosts []string) (*RestrictedNetwork, error)
CreateRestrictedNetwork creates a Docker internal network and a proxy sidecar container that enforces egress restrictions. The proxy container is created on Docker's default bridge (for internet access) and then connected to the internal network (for agent communication). The agent container should only be on the internal network.
func (*Manager) RemoveRestrictedNetwork ¶
func (m *Manager) RemoveRestrictedNetwork(ctx context.Context, rn *RestrictedNetwork) error
RemoveRestrictedNetwork tears down the proxy container and internal network. It attempts all cleanup steps even if individual steps fail.