Skip to content

Reference for building, pulling, pushing, tagging, moving and pruning images.

A sandbox boots from an image the server already has. Build, pull and push are jobs; the rest return a single result. See Working with images.

Member Does
build_image Job. Builds recipe and points reference (name:tag) at the result.
Recipe A base and the steps over it, each returning the recipe so they chain: run a command through sh -c, set an env variable for later steps and the image, or set the workdir.
pull_image Job. Pulls reference from its registry.
push_image Job. Pushes the image reference points at to the registry it names.
list_image Every tag on the server’s images, with the digest it points at.
tag_image Points the tag target at the image source names, moving it if it is in use.
untag_image Removes a tag, leaving the image; refused with 409 for the last tag of an image a sandbox or a build uses.
remove_image Removes the image and every tag on it in that name; refused with 409, with nothing removed, while a sandbox or a build uses it.
download_image Writes the image to an OCI image layout tar archive at path.
upload_image Uploads the image in an OCI archive and points the tag reference at it.
prune_image Deletes images no tag points at and no sandbox uses, once they are an hour old, and returns their digests and the bytes freed.

build_image

Job. Builds recipe and points reference (name:tag) at the result.

def build_image(recipe: Recipe | Mapping[str, Any], reference: str) -> StartedJob[ImageJob, ImageJobEntry]

Recipe

A base and the steps over it, each returning the recipe so they chain: run a command through sh -c, set an env variable for later steps and the image, or set the workdir. In Rust, Recipe::new(base).step(..) takes a Step::run, Step::env or Step::workdir, or a plain string as a run step, and Recipe::from_dockerfile(text) reads a Dockerfile.

Recipe(base).run(command).env(key, value).workdir(directory)

Recipe::from_dockerfile (and virtx build, which calls it) fails before anything is sent when the Dockerfile uses what a recipe can’t hold:

  • Dockerfile:N: … is not one of FROM, RUN, ENV and WORKDIR: another instruction, such as COPY or CMD. Write files in with the file calls, and start programs with exec.
  • Dockerfile:N: ENV with a bare word …: ENV key value, the old form. Write ENV key=value.
  • Dockerfile:N: a second FROM …, or a named stage …: a multi-stage Dockerfile. Use one stage, with one FROM and no AS.

pull_image

Job. Pulls reference from its registry. Without auth, anonymously; with it, a BasicAuth(username, password) or a BearerAuth(token).

def pull_image(reference: str, auth: RegistryAuth | None = None) -> StartedJob[ImageJob, ImageJobEntry]

push_image

Job. Pushes the image reference points at to the registry it names.

def push_image(reference: str, auth: RegistryAuth | None = None) -> StartedJob[ImageJob, ImageJobEntry]

list_image

Every tag on the server’s images, with the digest it points at.

async def list_image() -> list[ImageListOutputItem]

tag_image

Points the tag target at the image source names, moving it if it is in use.

async def tag_image(source: str, target: str) -> None

untag_image

Removes a tag, leaving the image; refused with 409 for the last tag of an image a sandbox or a build uses.

async def untag_image(reference: str) -> None

remove_image

Removes the image and every tag on it in that name; refused with 409, with nothing removed, while a sandbox or a build uses it.

async def remove_image(reference: str) -> None

download_image

Writes the image to an OCI image layout tar archive at path. Yields Progress events, each a line of log, then what it wrote.

def download_image(reference: str, path: str | os.PathLike[str]) -> AsyncIterator[Event[ImageDownloadOutput, str]]

upload_image

Uploads the image in an OCI archive and points the tag reference at it. Yields Progress events, then what it uploaded.

def upload_image(path: str | os.PathLike[str], reference: str) -> AsyncIterator[Event[ImageUploadOutput, str]]

prune_image

Deletes images no tag points at and no sandbox uses, once they are an hour old, and returns their digests and the bytes freed.

async def prune_image() -> ImagePruneOutput

Errors

A call that fails raises a VirtxError in Python, throws one in Node.js, and returns one in Rust. Branch on its status and code, not its message. These are the errors the calls on this page return most often.

Error From Cause
… is not reachable from this server: it is not a public address pull_image, push_image On your own server, the registry is on its machine or private network. List it in private_registries.
409 remove_image, untag_image A sandbox or a build stands on the image, and no other tag names it. The OCI code is DENIED. Remove the sandbox, or let the build finish.
source job Awaiting a build, pull or push The job failed, such as a build step that exited nonzero. Its log says why.

Any call can also fail with 401, unauthorized or 403, forbidden (see Client), or with source transport when the connection drops. The client retries 503, capacity and a 429, quota for the request rate by itself for up to 30 seconds: see Retries.