Skip to Content

Custom templates

Preview

Start sandboxes from your own container image. Deploy the image as a template, read its build, start sandboxes from it, and delete it.

A custom template is a container image that you deploy to your workspace under a name. Munito AI builds the image into a template one time. Each sandbox of the template then starts with the files of the image.

  • The image comes from a public registry, such as Docker Hub, or from a private registry.
  • The image is for linux/amd64.
  • A sandbox of a custom template has each feature of a sandbox: sizes, larger disks, commands, files, ports, SSH, persistence and fork.

Deploy an image

The munito templates commands need version 0.3.0 or later of the command line tool.

munito templates deploy acme-agent ghcr.io/acme/agent:1.4

The API answers at once with the template, and the build continues. A build takes from seconds to minutes. A larger image takes more time.

  • A name has 1 to 63 lower case letters, digits and hyphens. It starts and ends with a letter or a digit.
  • The name of a built-in template, such as base, is not available.
  • A new name makes a new template. Its id starts with tpl_.
  • A name that exists gets a new version. The last ready version starts new sandboxes until the new version is ready.
  • Give the image with a tag or a digest. An image without a tag or a digest gets the tag latest.
  • An image name without a registry, such as python:3.12-slim, is on Docker Hub.

The Sandboxes console also deploys, shows and deletes templates.

Read the build

munito templates get acme-agent --wait

--wait reads the template every 5 seconds until its build ends. When the build fails, the command shows the error and the end of the build output, and exits with code 1.

FieldMeaning
statusready when a version starts sandboxes. Before that, building, or failed if the newest build failed
version, image, digest, size_bytesThe version that new sandboxes start from. null before a version is ready
buildThe newest version. It can build or fail while an older version starts new sandboxes
build.errorWhy the build failed: a code and a message
build.logThe end of the build output, when the build failed

munito templates ls and GET /templates list the templates of your workspace, by name.

Start a sandbox

Set the name of the template, or its id, in template:

munito create --template acme-agent --size small
munito run "python3 --version" --template acme-agent

  • The sandbox starts from the ready version of the template.
  • A sandbox of a custom template has 512 MiB of memory or more, so the tiny size is not available.
  • The sandbox boots from the files of the template, and does not restore from a snapshot. It starts in about a second.
  • A host that does not have the template yet downloads it before the first start.
CodeStatusWhen
template_not_found404The workspace has no template with this name or id
template_not_ready409The template has no ready version. Wait for its build

Private registry

Give a user name and a password, or an access token, in registry_auth:

echo "$REGISTRY_TOKEN" | munito templates deploy acme-agent ghcr.io/acme/agent:1.4 \
  --username acme --password-stdin

  • The build uses the credential one time. Munito AI does not keep it, and no answer contains it.
  • Each deploy of a private image needs the credential again.
  • The command line tool reads the token from standard input with --password-stdin, or from the variable MUNITO_REGISTRY_TOKEN. It has no flag for the token, so the token stays out of your shell history.
  • Use a token that can only read images. For GitHub Container Registry, use a token with the read:packages scope.

What runs in the sandbox

  • Commands run as root in /workspace, with the environment (ENV) of the image.
  • The ENTRYPOINT and the CMD of the image do not run. To start the server of the image, run its command as a background command.
  • The WORKDIR of the image is not the work folder. To run a command there, set cwd.
  • A string command runs in bash -lc. If the image has no bash, the command runs in /bin/sh.
  • If the image has no shell, the command runs in a BusyBox shell. Munito AI adds it in /opt/munito.
  • SSH, ports, files, persistence and fork operate as in the other templates.

Limits and price

LimitValue
Platform of the imagelinux/amd64
Files of the image9 GiB or less. The disk of a template is 10 GiB
Time of a build20 minutes or less
Templates in a workspace10
Builds at the same time in an organization2
  • During the preview, the build and the storage of a template are free.
  • A sandbox of a custom template pays the price of its size, as each sandbox does.
  • To get a larger root disk, set disk_gib when you create the sandbox.
CodeStatusWhen
invalid_request422The name or the image name is not valid
template_limit409The workspace has 10 templates. Delete one, or deploy a name that exists
build_limit429Your organization has 2 builds now. Deploy again when one ends
no_capacity503No host has room for the build. Retry after the Retry-After seconds

Delete a template

munito templates rm acme-agent

  • A delete removes the template and each of its versions.
  • The sandboxes that run from the template continue to run.
  • A delete cannot be reversed. To use the image again, deploy it again.