Skip to content
Français

createDockerSandboxProvider

import { createDockerSandboxProvider } from "@elie-laloum/outpost/providers/docker";

Create the Docker provider, used when sandboxProvider is omitted. By default the worktree and its Git metadata are mounted at /workspace; repositoryMode isolated uploads the history instead. Each acquire creates a container, and release removes it.

Complete example and detailed rules.

  • optionsOptional
    ContainerOptions | undefined
    Container image, repository mode, mounts, environment, network and resource limits.
  • options.egressOptional
    EgressPolicy | undefined
    deny-all uses the none network. An allowlist starts a dedicated proxy and namespace firewall before sandbox commands: domains allow HTTP on port 80 and HTTPS CONNECT on 443 with matching TLS SNI; CIDRs allow raw TCP/UDP, with denyCidrs taking precedence. Explicit networks conflict with an allowlist. See the network guide for image publication and validation limits.
  • options.egressImageOptional
    string | undefined
    Override the trusted companion image for an allowlist. Use an immutable digest in production. The engine downloads a missing image. Omitting this option uses the public amd64/arm64 image pinned by verified digest in Outpost. Build images/egress and set this explicitly to test a local companion. The image must implement the matching Outpost egress runtime protocol.
  • options.repositoryModeOptional
    "mounted" | "isolated" | undefined
    mounted (default) mounts the worktree at /workspace with its Git metadata. isolated makes the provider remote: the history is uploaded to /tmp/outpost/workspace, volumes cannot expose the host repository, and durable speculation recovery is unavailable.
  • options.cachesOptional
    readonly DependencyCache[] | undefined
    Named engine volumes mounted at /outpost/cache/<name> that outlive the sandbox. The volume is derived from repository, image, user, name and key; explicit volumes must not overlap /outpost/cache.
  • options.imageOptional
    string | undefined
    Image to run, default outpost:<repository directory name>. When user is unset and the image declares another numeric user than yours, acquisition fails with code provider.
  • options.userOptional
    { readonly uid: number; readonly gid: number; } | undefined
    UID and GID of sandbox commands, default your host IDs (1000:1000 where unavailable). UID 65532 is reserved for the dedicated egress proxy when an allowlist is configured.
  • options.volumesOptional
    readonly Volume[] | undefined
    Extra host mounts into the container.
  • options.imageMountsOptional
    readonly ContainerImageMount[] | undefined
    Read-only mounts of images already present on the engine host, with the ContainerImageMount rules. Unlike volumes, they read no path on the machine running Outpost, so they also work with a remote engine. Provider creation validates every entry, including unknown fields and reserved targets, and throws a ConfigurationError located at imageMounts.<index>. Outpost neither pulls nor checks the images: a missing image makes the engine fail to start the sandbox, with Podman’s image not known or Docker’s No such image. Image mounts always use —mount syntax; label does not apply to them.
  • options.variablesOptional
    Readonly<Record<string, string>> | undefined
    Environment variables set for every command in the sandbox, as literal values. A key the agent also declares fails with code configuration.
  • options.networksOptional
    string | readonly string[] | undefined
    Engine networks passed as —network. An egress allowlist refuses explicit networks because Outpost owns the filtered network namespace.
  • options.groupsOptional
    readonly (string | number)[] | undefined
    Supplementary groups for the container user, passed as —group-add.
  • options.devicesOptional
    readonly string[] | undefined
    Host devices exposed to the container, passed as —device.
  • options.cpusOptional
    number | undefined
    CPU limit passed as —cpus; must be positive.
  • options.memoryMbOptional
    number | undefined
    Memory limit in megabytes, an integer of at least 64.
  • options.labelOptional
    false | "z" | "Z" | undefined
    SELinux relabeling of bind mounts on Linux: z shared (default), Z private, false plain bind mounts.
  • options.labelsOptional
    Readonly<Record<string, string>> | undefined
    Caller labels set by the create command of the sandbox container and of its egress companion, so they exist as soon as the container does, with the ContainerLabels rules. Invalid or reserved labels fail at provider creation with a ConfigurationError located at labels.<key>; a reserved key also carries a hint. listDockerSandboxes and listPodmanSandboxes find sandboxes by these labels. Unrelated to label, which controls SELinux relabeling.
  • options.retainOptional
    number | undefined
    Bytes of output tail kept per stream, default 65536.
  • options.usernsOptional
    false | "keep-id" | undefined
    Podman user namespace: keep-id maps your user and applies by default when Outpost does not run as root; false disables it. Docker ignores it.

SandboxProvider

export declare const createDockerSandboxProvider: (
  options?: ContainerOptions,
) => SandboxProvider;