---
title: Templates from images
description: Build a template from a public OCI image or a Dockerfile, and start sandboxes from the eokit-default office image.
---

Besides [saving a prepared sandbox](/docs/sandboxes/templates/), you can build a template from a container image: a public OCI image, a Dockerfile, or a Git repository or tarball with its own Dockerfile. pols also provides a second system template, `eokit-default`, with office tools for agents that work with Word, Excel and PowerPoint files.

```sh
pols template build py312 --image python:3.12-slim
pols template build app --dockerfile ./Dockerfile
pols template build app --context https://github.com/org/repo.git#main:docker
pols new --name review --template py312
```

## Building a template

`pols template build NAME` (`POST /v1/templates` with `name` and `image`, `dockerfile` or `context`) builds the template and waits until it is ready. It takes one of:

| Flag | API field | What is built |
| --- | --- | --- |
| `--image REF` | `image` | a public OCI image, such as `python:3.12`, `ghcr.io/org/app:tag` or `name@sha256:...` |
| `--dockerfile FILE` | `dockerfile` | a Dockerfile (`-` reads it from stdin; at most 64 KiB), built in `--context` or in an empty context |
| `--context URL` | `context` | a public build context as `docker build` takes it: a Git repository (`https://host/org/repo.git`, optionally `#ref:dir`) or a tarball; on its own, built with its own `Dockerfile` |

`--size` sets the size of the build sandbox, whose disk the template gets (default `small`, 20 GiB); `--description` says what the template is for.

The build runs in a build sandbox of your org with access to the public internet, never on the host: pols pulls or builds the image there, adds its files to the default template's and saves the result. The template is `building`, then `creating`, then `ready`; over the API, poll `GET /v1/templates/{template}` until it is `ready`. A failed build stays `failed`, with `error` saying why and the end of the build's output, until you delete it.

A built template is an ordinary template of your org: sandboxes are made from it with `--template`, it counts against your org's 10 templates, and its disk is billed like any template's. The build sandbox is billed as sandbox time while the build runs and does not count against your sandbox [quotas](/docs/getting-started/limits/#quotas). Your org builds one template at a time; a second build at once is refused with `409 conflict`.

## What a sandbox from it gets

A sandbox from a built template is the default sandbox with the image's files added, so it still boots, has its desktop, its agent tools and its users:

- **The base's files win**, such as systemd, the accounts in `/etc/passwd`, `/etc` and the system libraries, **except under `/usr/local` and `/opt`**, where the image's files replace the base's. A directory the image ships at `/usr/local/NAME` (such as `go`), `/usr/local/lib/NAME` (such as `python3.12`), `/usr/local/include/NAME`, `/usr/local/lib/node_modules/PKG` or `/opt/NAME` replaces the base's whole. So a `node:20` image's Node.js and npm replace the base's Node.js 24; the preinstalled agents need Node.js 18 or later.
- **Chrome stays the base's.** The desktop's Chrome in `/opt/google` wins over an image's own `google-chrome`, so Puppeteer and Selenium still get a working Chrome.
- **New files come along**, such as `/app` or the files of apt packages the base lacks. The base's package database does not list those packages. Ownership is kept by number.
- **The image's `ENV`** (other than `HOME`, `USER`, `SHELL` and the like) is exported to login shells (`bash -lc`, SSH). A command run without a shell gets only its own environment.
- **`ENTRYPOINT`, `CMD`, `USER`, `WORKDIR`, `EXPOSE`, `VOLUME`, `HEALTHCHECK` and the image's accounts are not used.** Commands run as the sandbox user or root, in their home unless you pass `--cwd`. Start the image's process yourself with `pols exec`, a [detached process](/docs/sandboxes/processes/) or a systemd unit.

Images without a shell, such as distroless or `scratch` images, work too, since the base has one.

## Limits

- Public images only; there is no registry login. Docker Hub's limit on anonymous pulls is shared by the host.
- `linux/amd64` only: an image without an amd64 variant fails saying so.
- At most 10 GiB unpacked, with room for its files beside its layers on the build sandbox's disk; otherwise the build fails and asks for a larger `--size`.
- 30 minutes from the request until the image's files are in place.

## The eokit-default template

`eokit-default` is a second system template next to `ubuntu-24.04`, provided for every org. It is the default image plus what an agent needs to open, edit and look at Word, Excel and PowerPoint files:

```sh
pols new --name docs --template eokit-default
pols exec docs -- office-python edit.py           # import docx, openpyxl, pptx
pols exec docs -- office-render report.docx       # report-render/report.pdf and one PNG per page
```

| Area | Contents |
| --- | --- |
| Office | LibreOffice Writer, Calc and Impress (`libreoffice`, `soffice`), headless and on the desktop, set up without first-start dialogs or format questions when saving `.docx`, `.xlsx` and `.pptx` |
| Fonts | Carlito (metric-compatible with Calibri), Caladea (Cambria) and Liberation (Arial, Times New Roman, Courier New). Microsoft's own core fonts are not included. |
| Python | python-docx, openpyxl and python-pptx in their own environment, run with `office-python`; it is never on `PATH`, so it does not shadow a project's `python3`, `pip` or packages |
| Rendering | `office-render [--out DIR] [--dpi N] [--timeout SECONDS] FILE` renders anything LibreOffice opens to a PDF and one PNG per page (100 dpi by default) and prints their paths, the PDF first |

The loop for an agent: edit a file with `office-python`, render it with `office-render`, look at the PNGs, correct. `office-render` writes to `NAME-render` next to the file unless you pass `--out`, and limits the conversion and the PNGs to 120 seconds each (exit code 124 when that is hit). To open a file on the desktop, run `DISPLAY=:1 libreoffice FILE`.

A sandbox from `eokit-default` boots its own VM instead of taking a pre-booted one, so it takes longer to start than one from `ubuntu-24.04`.

## From agents and code

The Python client builds templates with `templates.build(name, image=..., dockerfile=..., context=...)`, the TypeScript client with `templates.create`. The [MCP server](/docs/agents/mcp/) has no template tools; `sandbox_create` takes `template`, so agents can start sandboxes from `eokit-default` or a built template.
