Documentation
¶
Index ¶
- func ContainerName(id string) string
- type CgroupManager
- type DockerRuntime
- func (r *DockerRuntime) Create(ctx context.Context, id string, cfg runtime.SandboxConfig) error
- func (r *DockerRuntime) EnsureNetwork(ctx context.Context) error
- func (r *DockerRuntime) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (*runtime.ExecResult, error)
- func (r *DockerRuntime) ExecStream(ctx context.Context, id string, opts runtime.ExecOpts) (runtime.ExecStream, error)
- func (r *DockerRuntime) Info(ctx context.Context, id string) (*runtime.SandboxInfo, error)
- func (r *DockerRuntime) List(ctx context.Context) ([]runtime.SandboxInfo, error)
- func (r *DockerRuntime) ListDir(ctx context.Context, id string, path string) ([]runtime.FileInfo, error)
- func (r *DockerRuntime) ListSnapshots(ctx context.Context, sandboxID string) ([]runtime.SnapshotInfo, error)
- func (r *DockerRuntime) MkDir(ctx context.Context, id string, path string) error
- func (r *DockerRuntime) Ping(ctx context.Context) error
- func (r *DockerRuntime) ReadFile(ctx context.Context, id string, path string) ([]byte, error)
- func (r *DockerRuntime) Remove(ctx context.Context, id string) error
- func (r *DockerRuntime) RemoveFile(ctx context.Context, id string, path string) error
- func (r *DockerRuntime) RemoveSnapshot(ctx context.Context, snapshotID string) error
- func (r *DockerRuntime) Restore(ctx context.Context, snapshotID string) (string, error)
- func (r *DockerRuntime) Snapshot(ctx context.Context, id string, name string) (*runtime.SnapshotInfo, error)
- func (r *DockerRuntime) Start(ctx context.Context, id string) error
- func (r *DockerRuntime) Stats(ctx context.Context, id string) (*runtime.SandboxStats, error)
- func (r *DockerRuntime) Stop(ctx context.Context, id string, timeout time.Duration) error
- func (r *DockerRuntime) UpdateMemoryLimit(ctx context.Context, id string, memoryBytes int64) error
- func (r *DockerRuntime) WriteFile(ctx context.Context, id string, path string, content []byte) error
- type Option
- type PortForwarder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerName ¶ added in v0.0.6
ContainerName returns the Docker container name for a sandbox ID.
Types ¶
type CgroupManager ¶ added in v0.0.6
type CgroupManager struct {
// contains filtered or unexported fields
}
CgroupManager handles dynamic memory limits for containers.
func NewCgroupManager ¶ added in v0.0.6
func NewCgroupManager(cli *client.Client, logger *slog.Logger) *CgroupManager
NewCgroupManager creates a new CgroupManager.
func NewCgroupManagerFromRuntime ¶ added in v0.0.6
func NewCgroupManagerFromRuntime(rt *DockerRuntime) *CgroupManager
NewCgroupManagerFromRuntime creates a CgroupManager from an existing DockerRuntime.
func (*CgroupManager) UpdateMemoryHigh ¶ added in v0.0.6
func (cm *CgroupManager) UpdateMemoryHigh(ctx context.Context, containerID string, memoryHigh int64) error
UpdateMemoryHigh sets the memory soft limit (cgroup v2 memory.high) for a container. On Linux, it writes directly to the cgroup v2 memory.high file (throttle, not OOM kill). Falls back to Docker API if direct write fails. On macOS/Docker Desktop, it sets the hard memory limit via Docker API (best effort).
func (*CgroupManager) UpdateOOMScore ¶ added in v0.0.6
UpdateOOMScore sets the OOM score adjustment for a container's main process. Only works on Linux.
type DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
DockerRuntime implements runtime.Runtime using Docker containers.
func (*DockerRuntime) Create ¶
func (r *DockerRuntime) Create(ctx context.Context, id string, cfg runtime.SandboxConfig) error
Create creates a new Docker container for the sandbox.
func (*DockerRuntime) EnsureNetwork ¶
func (r *DockerRuntime) EnsureNetwork(ctx context.Context) error
EnsureNetwork creates the den Docker network if it doesn't exist.
func (*DockerRuntime) Exec ¶
func (r *DockerRuntime) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (*runtime.ExecResult, error)
Exec runs a command synchronously inside the container and returns the result.
func (*DockerRuntime) ExecStream ¶
func (r *DockerRuntime) ExecStream(ctx context.Context, id string, opts runtime.ExecOpts) (runtime.ExecStream, error)
ExecStream runs a command inside the container and returns a streaming interface.
func (*DockerRuntime) Info ¶
func (r *DockerRuntime) Info(ctx context.Context, id string) (*runtime.SandboxInfo, error)
Info returns information about the sandbox container.
func (*DockerRuntime) List ¶
func (r *DockerRuntime) List(ctx context.Context) ([]runtime.SandboxInfo, error)
List returns all den-managed containers.
func (*DockerRuntime) ListDir ¶
func (r *DockerRuntime) ListDir(ctx context.Context, id string, path string) ([]runtime.FileInfo, error)
ListDir lists the contents of a directory in the container.
func (*DockerRuntime) ListSnapshots ¶
func (r *DockerRuntime) ListSnapshots(ctx context.Context, sandboxID string) ([]runtime.SnapshotInfo, error)
ListSnapshots returns all snapshots, optionally filtered by sandbox ID.
func (*DockerRuntime) Ping ¶
func (r *DockerRuntime) Ping(ctx context.Context) error
Ping verifies Docker daemon connectivity.
func (*DockerRuntime) ReadFile ¶
ReadFile reads a file from the container using Docker's CopyFromContainer API. This is significantly faster than exec-based cat approach.
func (*DockerRuntime) Remove ¶
func (r *DockerRuntime) Remove(ctx context.Context, id string) error
Remove forcefully removes the container.
func (*DockerRuntime) RemoveFile ¶
RemoveFile removes a file or directory from the container.
func (*DockerRuntime) RemoveSnapshot ¶
func (r *DockerRuntime) RemoveSnapshot(ctx context.Context, snapshotID string) error
RemoveSnapshot removes a snapshot image.
func (*DockerRuntime) Snapshot ¶
func (r *DockerRuntime) Snapshot(ctx context.Context, id string, name string) (*runtime.SnapshotInfo, error)
Snapshot commits the current container state as a new Docker image.
func (*DockerRuntime) Start ¶
func (r *DockerRuntime) Start(ctx context.Context, id string) error
Start starts the container.
func (*DockerRuntime) Stats ¶
func (r *DockerRuntime) Stats(ctx context.Context, id string) (*runtime.SandboxStats, error)
Stats returns resource usage stats for the sandbox.
func (*DockerRuntime) UpdateMemoryLimit ¶ added in v0.0.6
UpdateMemoryLimit dynamically updates the memory limit for a container.
type Option ¶
type Option func(*DockerRuntime)
Option configures the DockerRuntime.
func WithNetworkID ¶
WithNetworkID sets the Docker network to attach sandboxes to.
type PortForwarder ¶
type PortForwarder struct {
// contains filtered or unexported fields
}
PortForwarder manages dynamic TCP port forwarding for sandboxes.
func NewPortForwarder ¶
func NewPortForwarder(logger *slog.Logger) *PortForwarder
NewPortForwarder creates a new PortForwarder.
func (*PortForwarder) Forward ¶
func (pf *PortForwarder) Forward(ctx context.Context, sandboxID string, sandboxIP string, mapping runtime.PortMapping) (int, error)
Forward creates a TCP proxy from hostPort to sandboxIP:sandboxPort. If hostPort is 0, a random port is assigned.
func (*PortForwarder) Remove ¶
func (pf *PortForwarder) Remove(sandboxID string, sandboxPort int) error
Remove stops port forwarding for the given sandbox and port.
func (*PortForwarder) RemoveAll ¶
func (pf *PortForwarder) RemoveAll(sandboxID string)
RemoveAll stops all port forwarding for the given sandbox.