docker

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerRuntime

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

DockerRuntime implements runtime.Runtime using Docker containers.

func New

func New(opts ...Option) (*DockerRuntime, error)

New creates a new DockerRuntime.

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

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

Info returns information about the sandbox container.

func (*DockerRuntime) List

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) MkDir

func (r *DockerRuntime) MkDir(ctx context.Context, id string, path string) error

MkDir creates a directory in the container.

func (*DockerRuntime) Ping

func (r *DockerRuntime) Ping(ctx context.Context) error

Ping verifies Docker daemon connectivity.

func (*DockerRuntime) ReadFile

func (r *DockerRuntime) ReadFile(ctx context.Context, id string, path string) ([]byte, error)

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

func (r *DockerRuntime) RemoveFile(ctx context.Context, id string, path string) error

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) Restore

func (r *DockerRuntime) Restore(ctx context.Context, snapshotID string) (string, error)

Restore creates a new sandbox from 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

Stats returns resource usage stats for the sandbox.

func (*DockerRuntime) Stop

func (r *DockerRuntime) Stop(ctx context.Context, id string, timeout time.Duration) error

Stop stops the container with the given timeout.

func (*DockerRuntime) WriteFile

func (r *DockerRuntime) WriteFile(ctx context.Context, id string, path string, content []byte) error

WriteFile writes a file to the container using Docker's CopyToContainer API. This is significantly faster than exec-based tee approach.

type Option

type Option func(*DockerRuntime)

Option configures the DockerRuntime.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets the logger.

func WithNetworkID

func WithNetworkID(id string) Option

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.

Jump to

Keyboard shortcuts

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