Skip to content

Architecture

A deep dive into phases, versioned and layered images for containers and micro-VMs.

Build with agents
On this page

Beams are Kata containers that run in Cloud Hypervisor micro-VMs.

Phases are versioned and layered images for beam runtimes. A phase holds filesystem state and its build instructions.

Phases deliver a Git-like UX for container filesystems, combining continuous updates with persistent snapshots that you can fork and rebase from.

Unlike docker using layers to cache often stale build command results, phases use layers to represent reusable build stages, which beams rebuild automatically or users create interactively, like VM snapshots.

Phases let you:

  • Define build stages in YAML, with automated periodic rebuilds.
  • Write to /home interactively, and take snapshots.
  • Copy local files into the container and persist them.
  • Receive automatic updates to base layers via rebasing.

You can apply these steps in any order, creating a pipeline that composes mutable, immutable, and regenerated state, with rules that prevent unsafe mutations and data corruption.

Each step is called a phase. When a parent image refreshes, child phases compose a new image on top of it. Only rebuild phases rerun commands.

Phase cycle

On refresh, regenerate rebuild layers and retain snapshot layers.

  • Base Base image 83c3f21a… 4b6a09ef… Rebuilt
  • Rebuild Outside /home b0193e72… 6ac8f931… Rebuilt
  • Snapshot /home c0174a0b… Retained
  • Rebuild Outside /home d01a520c… 91eb604a… Rebuilt
  • Snapshot /home e01721d8… Retained
Manifest sha256:f001a89c… sha256:2e74b90c…

Overview

There are three types of phases:

  • Snapshot phases, which persist your changes in /home in durable (but editable and forkable) layers. You can edit these until descendant snapshot phases depend on them – then you have to fork.
  • Rebuild phases, which periodically rerun commands to make changes outside of /home (like a Dockerfile on a timer). You can change the commands between rebuilds.
  • Copy phases, which supply fixed sets of files outside of /home (base image overlays, like Dockerfile’s COPY --link). You can always edit these.
Filesystem areas

Separate saved home files from the paths managed by rebuild and copy phases.

/

Rebuild

/usr/   /etc/   …

Outside /home

+ Copy

/opt/dev/

Copy and rebuild paths can overlap.

Snapshot

/home/beams/

Saved interactive files

Let’s review a couple of examples. If you want to run the commands yourself, set up tsh in your local terminal first.

Install the client tools and sign in

Beams is a Teleport project and uses official Teleport client tools.

The client tools include tsh to sign in and run commands, and tctl to administer your cluster if you have permission.

Cluster: example.beams.run. Edit this example to use your cluster name.

Install version 18.11.10 of the client:

Operating system
macOS

Download and open the macOS installer, then follow its instructions.

CLI
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkg
Linux

For Linux x86-64, download and install the client tools:

CLI
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/install
Windows

For Windows x86-64, run these commands in PowerShell. Add the extraction directory ($env:LOCALAPPDATA\Teleport) to your user PATH to use tsh in future terminals; the last command adds it to this terminal's PATH.

PowerShell
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"

Follow the official client tools install guide for other versions and architectures.

Check that you’re running v18.11.10 of the client with tsh version.

CLI
tsh version
Sign-in method
Passwordless

I sign in without a password (e.g. a passkey).

CLI
tsh login --proxy='example.beams.run' --auth=passwordless
Password & MFA

I have a password & MFA set up for my account:

Replace you@example.com with your Teleport username.

CLI
tsh login --proxy='example.beams.run' --user=you@example.com
SSO

I sign in with SSO (e.g. Okta, GitHub, SAML).

CLI
tsh login --proxy='example.beams.run'

MicroVMs with snapshots and forks

A snapshot saves files, not running processes or memory. A fork gives you an independent copy of those files. For example, create a workspace from your local terminal:

CLI · Local terminal
tsh phase add workspace --from=default:v1

Inside the build beam, save a file:

CLI · Inside the workspace build beam
printf '%s\n' 'original workspace' > ~/notes.txt
tsh phase snapshot --final

Back in your local terminal, open a fork of the saved workspace:

CLI · Local terminal
tsh phase add beak-buttons --fork-from=workspace

Inside the fork, cat ~/notes.txt should print original workspace. Save a different value:

CLI · Inside the beak-buttons build beam
printf '%s\n' 'beak buttons experiment' > ~/notes.txt
tsh phase snapshot --final

Now start another fork from workspace with tsh phase add flock-chat --fork-from=workspace in your local terminal. In that build beam, cat ~/notes.txt should still print original workspace; the first fork changed only its own copy. For more, see Forks.

Two independent forks

Fork saved workspace files into independent environments with a shared base.

base

Shared environment parent

workspace

Saved /home stays intact

beak-buttons

Independent /home copy

flock-chat

Independent /home copy

base → workspace, beak-buttons, flock-chat

Compose a copy, rebuild, and snapshot pipeline

This example builds a small text page without a repository, package install, or external service. Use a new directory on your workstation. Save this file as message.txt:

Text
Hello from the copy layer

Save this as phase.yaml in the same directory. The copy layer adds the message under /opt/dev. The rebuild layer prepares a display version outside /home using a command that can rerun when the base changes.

YAML · phase.yaml
version: v1
metadata:
  name: dev-files
  from: default:v1
files:
  - from: ./message.txt
    to: /opt/dev/message.txt
---
version: v1
metadata:
  name: environment
  from: dev-files
commands:
  - shell: tr '[:lower:]' '[:upper:]' < /opt/dev/message.txt > /opt/dev/banner.txt

Apply the configuration, then create the dev snapshot phase on top of it:

CLI · Local terminal
tsh phase apply -f phase.yaml &&
  tsh phase add dev --from=environment

In the build beam that opens, save the part you want to edit interactively:

CLI · Inside the dev build beam
printf '%s\n' 'Saved in the snapshot' > ~/caption.txt
tsh phase snapshot --final

Finally, add a second rebuild layer that reads both inputs and assembles the page. Save this as app.yaml on your workstation:

YAML · app.yaml
version: v1
metadata:
  name: app
  from: dev
commands:
  - shell: cat /opt/dev/banner.txt /home/beams/caption.txt > /opt/dev/page.txt

Apply it and start a fresh beam from the resulting image:

CLI · Local terminal
tsh phase apply -f app.yaml &&
  tsh beams add --phase=app

Inside the new beam, verify the copy input, the snapshot input, and the assembled output:

CLI · Inside the app beam
grep -Fx 'Hello from the copy layer' /opt/dev/message.txt &&
  grep -Fx 'Saved in the snapshot' ~/caption.txt &&
  printf '%s\n' 'HELLO FROM THE COPY LAYER' 'Saved in the snapshot' | cmp - /opt/dev/page.txt

The check prints the two input lines and exits successfully if page.txt contains exactly the uppercase banner followed by the saved caption.

An editable build pipeline

Compose copy, rebuild, and editable snapshot stages in one pipeline.

  1. base

    Image

  2. dev-files

    Copy

  3. environment

    Rebuild

  4. dev

    Snapshot

  5. app

    Rebuild

environment → dev

banner.txt · generated

caption.txt · saved in dev

app → runtime

page.txt · banner + caption

tsh phase edit devEdit and save dev → rebuild app

dev is still editable, even though app depends on it. From your workstation, run tsh phase edit dev. In the build beam that opens, change ~/caption.txt and run tsh phase snapshot --final again. Saving dev triggers a rebuild of app. After the rebuild succeeds, a new beam from app will have the same banner and the updated caption in /opt/dev/page.txt. Beams that are already running keep their original image.

Phases are rebuilt continuously, with upstream changes triggering downstream changes. Only rebuild phases need to execute build commands during a refresh. Snapshot and copy phases are quickly stitched on top of new layers by updating image registry metadata.

By default, snapshots own /home, and rebuilds own everything else. You can also give a rebuild phase specific paths inside /home, like node_modules, using metadata.rebuild_home_paths. Later snapshots must leave those paths alone.

Phases provide a single model for container persistence and security patching that covers agentic development workflows, dev environments, building apps, and whatever else you do in containers.

Compatibility

Updating dependencies underneath a saved workspace is only useful if you can control which updates you get. For Teleport Beams, we start with a stable Debian base image, so OS security fixes arrive within an ABI-stable release. Rebuild phases rerun every 24 hours to pick up updates allowed by the commands you specify in phase.yaml, while snapshots preserve your work on top.

Tests can run as part of rebuilds as well, including long integration tests that require access to other services connected to Teleport. If the build fails, the previous published image stays available. You choose which updates to accept and how to test them in phase.yaml, and phases handle rebuilding the environment around your saved work.

How it works

The phases model can be implemented on any Linux-based platform that supports raw container primitives like OverlayFS, but here’s how we’ve implemented it for Teleport Beams.

Builds run in a Kubernetes pod, isolated in a Cloud Hypervisor microVM using Kata Containers. The pod has an unprivileged (but VM-like) user container and a privileged builder container. Before user code starts, a trusted launcher passes open file descriptors for the user container’s mount namespace, root, and cgroup to the builder over a Unix socket (SCM_RIGHTS). The builder enters that mount namespace, mounts an OverlayFS filesystem, and uses pivot_root to switch roots and detach the old root. The setup socket is then hidden from the user environment.

Build setup and snapshot capture

Isolated setup and snapshot capture inside a microVM, with an external OCI registry.

Kubernetes pod · Cloud Hypervisor microVM isolation

User container · unprivilegedBuilder · privileged
User container · unprivileged

Trusted launcher

Before user code

SCM_RIGHTSMount namespace / root / cgroup FDs
Builder · privileged

Private setup socket

Builder receives file descriptors

User container · unprivileged

User workload

OverlayFS root

Mount setup
Builder · privileged

setns → OverlayFS

pivot_root

Detach old root; hide setup socket

User container · unprivileged

Snapshot request

Separate user socket

Builder · privileged

Freeze → capture layer → thaw

Quiesce filesystem writes, then resume before upload

ggcr · upload / rebase

OCI registry

Layers + manifests · outside the pod

For snapshots, the builder freezes the workload’s cgroup to quiesce filesystem writes, captures the writable layer, then thaws it before uploading. Image assembly, rebasing, and registry operations use the go-containerregistry (ggcr) library to manipulate layers and manifests directly on the registry.

Retention and access control

Teleport Beams automatically garbage collects data: unused images are deleted in less than 2 days. Once cloud tenant is suspended, all data in image registry is deleted in less than 3 weeks.

Each region has a dedicated ECR repository in that region. Snapshots are region-locked and access to them is not possible outside of that region. Beams cannot pull, upload, or download snapshots across regions.

Users cannot directly pull, download, or upload snapshots, including from inside of a beam, regardless of region.

Search docs

Loading search and AI…

Skills

Install all available skills. All Beams and Teleport skills are hosted in our OSS Teleport repository.

npx skills add https://github.com/gravitational/teleport