Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Templates

A template is a reusable starting point for launching sandboxes. Build or import it once, then use it to create sandboxes whenever you need the same software and configuration.

Create Your Template

There are two ways to create a template: aenv pull imports an OCI image directly, and aenv build runs Dockerfile instructions inside a temporary build sandbox.

Some defaults below come from your AgentENV config file. This is config/default.toml by default, or the file specified by AENV_CONFIG_PATH.

aenv pull

Pull an existing OCI image as a template and optionally give it a memorable name:

Usage:

aenv pull <image> [options]

Example:

aenv pull ubuntu:24.04
aenv pull ubuntu:24.04 --name my-base

--name is optional. Without it, AgentENV uses the image repository name. A template name can be used anywhere a template ID is accepted.

Argument or optionDefaultDescription
<image>RequiredOCI image reference. Short names such as ubuntu:24.04 and full references are supported.
--name <name>Image repository nameAssign a human-readable template name.
--cpu <count>[machine].vcpu_count from your config fileSet the template’s vCPU count. Alias: --cpu-count.
--memory <MiB>[machine].mem_size_mib from your config fileSet the template’s memory. Aliases: --memory-mb, --mem.
--start-cmd <cmd>NoneRun a command before capturing the template snapshot.
--ready-cmd <cmd>sleep 20 when --start-cmd is set; otherwise nonePoll a shell command every two seconds until it exits successfully.
--probe <port>NoneWait for TCP on localhost:<port>. Cannot be combined with --ready-cmd.
-d, --detachOffSubmit the build and return immediately instead of waiting.
--timeout <seconds>No timeoutLimit how long the CLI waits for the build. Cannot be combined with --detach.

Env, WorkingDir, and User are automatically inherited from the OCI image config. See Runtime Configuration for the full field list.

aenv build

⚠️ Experimental — Not recommended for production use.

Build a template by running Dockerfile instructions inside a temporary sandbox:

aenv build <dockerfile> --name <name> [options]
Argument or optionDefaultDescription
<dockerfile>RequiredPath to the Dockerfile.
--name <name>RequiredAssign the template name.
--image <ref>First concrete FROM imageOverride the base image. If the Dockerfile has no usable FROM, [image.resolver].default_image from your config file is used. Alias: --user-image.
--cpu <count>[machine].vcpu_count from your config fileSet the template’s vCPU count. Alias: --cpu-count.
--memory <MiB>[machine].mem_size_mib from your config fileSet the template’s memory. Aliases: --memory-mb, --mem.

aenv build and aenv pull --detach submit the build and return immediately. Watch it until it succeeds or fails by passing the template name or ID:

aenv template watch my-template

aenv template watch has no timeout option. Stop the local watch with Ctrl-C; the remote build continues.

Supported Dockerfile instructions:

InstructionBehavior
FROMBase image (overridable with --image)
RUNShell command executed inside the build sandbox
ENVSet an environment variable
ARGSet a build-time variable
WORKDIRCreate the directory if needed and set it as the working directory
USERSet the default user (a missing named account is created at the end of the build)
ENTRYPOINTBecomes the template startCmd
CMDBecomes startCmd if no ENTRYPOINT is present
EXPOSE / VOLUME / LABELAccepted but stored as metadata only

Runtime Configuration

Both methods read the same set of OCI image config fields. For aenv pull, these come from the image config or flags; for aenv build, they are set by the corresponding Dockerfile instructions executed during the build. The following fields from the OCI image-spec config object are recognised:

OCI fieldDockerfile instructionRuntime effect
EnvENVEnvironment variables injected into every sandbox process
WorkingDirWORKDIRDefault working directory
UserUSERDefault user
Entrypoint / CmdENTRYPOINT / CMDMapped to startCmd for aenv build; use --start-cmd explicitly for aenv pull
ExposedPortsEXPOSEStored as metadata only
VolumesVOLUMEStored as metadata only
LabelsLABELStored as metadata only

Manage Templates

List templates

aenv template list        # alias: aenv template ls
aenv template list --output json

Displays all templates with their ID, name, build status, CPU, memory, disk size, and last-updated timestamp. --output accepts table or json. It defaults to table in an interactive terminal and json when output is piped or redirected.

List template builds

List the complete build history for one template:

curl -H 'X-API-Key: test-key' \
  http://127.0.0.1:8000/templates/<template-id>

Check a template alias

Check whether an alias exists and resolve it to a template ID:

curl -H 'X-API-Key: test-key' \
  http://127.0.0.1:8000/templates/aliases/<alias>

Delete a template

aenv template delete <template-id-or-name>   # alias: aenv template rm

Relationship to Snapshots

Templates are the API and UX layer. Snapshots are the durable runtime layer.

  • A template build publishes one committed snapshot.
  • A template ID or alias resolves to one committed snapshot.
  • A sandbox created from a template resumes from that snapshot.

If you want the storage and runtime model underneath templates, see Snapshots.