dockerexec

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dockerexec is an example sandbox implementation that runs each exec-hook invocation inside an already-running container via `docker exec -i`. This is the cheap sibling of dockerrun: no per-call container startup cost, just a docker exec that pipes stdin/stdout through.

Typical use case: a long-lived sidecar container in the same Compose stack that has the hook scripts and their runtime dependencies baked in. A nearby example: `kubectlexec` for the Kubernetes equivalent.

This is reference/example code — not imported by PromptKit core. Register via sdk.WithSandboxFactory or sandbox.RegisterFactory, or construct one directly and set it on ExecHookConfig.Sandbox.

Configuration:

mode: docker_exec
container: my-hooks-sidecar    # required
workdir: /app                  # optional; maps to --workdir
user: hookuser                 # optional; maps to --user
extra_args: [--tty]            # optional

Index

Constants

View Source
const ModeName = "docker_exec"

ModeName is the identifier under which this backend registers with sandbox.RegisterFactory.

Variables

This section is empty.

Functions

func Factory

func Factory(name string, cfg map[string]any) (sandbox.Sandbox, error)

Factory is a sandbox.Factory compatible with RuntimeConfig-based resolution.

Types

type Config

type Config struct {
	// Container is the name or ID of the running container to exec into.
	// Required.
	Container string
	// Workdir maps to `docker exec --workdir=<value>`. Empty means don't
	// pass the flag.
	Workdir string
	// User maps to `docker exec --user=<value>`. Empty means don't pass
	// the flag.
	User string
	// ExtraArgs are extra `docker exec` flags inserted after the
	// standard ones and before the container name.
	ExtraArgs []string
	// DockerPath overrides the `docker` binary name. Empty uses `docker`
	// resolved from PATH.
	DockerPath string
}

Config configures the docker-exec backend.

type Sandbox

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

Sandbox runs exec-hook commands via `docker exec` in an existing container.

func New

func New(cfg Config) *Sandbox

New constructs a Sandbox from a Config.

func NewNamed

func NewNamed(name string, cfg Config) *Sandbox

NewNamed is like New but lets the caller override the sandbox name.

func (*Sandbox) Name

func (s *Sandbox) Name() string

Name returns the sandbox's name.

func (*Sandbox) Spawn

func (s *Sandbox) Spawn(ctx context.Context, req sandbox.Request) (sandbox.Response, error)

Spawn builds a `docker exec -i [flags] <container> <cmd> <args...>` argv and delegates to the inner direct sandbox.

Jump to

Keyboard shortcuts

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