Skip to content

Images and the runtime

Choose a starter image or bring your own, and see what Legion adds to every rental.

On this page

Every rental runs one container image. Use one of Legion's starter images, or any Linux image of your own, public or private.

Starter images

Starter images
Catalog idImageCUDADriverPyTorchDownload
pytorchPyTorch 2.14 (default)13.0580+2.14.13.38 GB
pytorch-jupyterPyTorch 2.14 + JupyterLab13.0580+2.14.13.42 GB
cudaCUDA 13.013.0.3580+None1.73 GB
pytorch-cu128PyTorch 2.11 (CUDA 12.8)12.8570+2.11.06.2 GB
cuda-12CUDA 12.812.8.2570+None2.16 GB

On the rent form's Software step, choose Starter image, Model or Your own image under What to run. Every starter image is a tile that says what's inside it, and the one you choose is described in full beside the tiles. One the host can't run is shown greyed out, with the reason, for example a driver that's too old for its CUDA version. The newest image the host can run is chosen for you.

On starter images:

  • /workspace is the folder a backup copies. Keep your work there. After a rental stops, its files stay on the host for at least 24 hours and at most 72 hours, then are deleted. An interruptible rental set to delete on preemption loses them when preempted. See Stopping, backups and how long your data is kept.

  • Common tools are installed, such as git, rsync, tmux and jq.

  • pip install goes into the system Python.

Your own image

Choose Your own image and enter the image reference. The image can be on one of these registries:

  • docker.io

  • ghcr.io

  • nvcr.io

  • quay.io

Write the whole reference, such as ghcr.io/acme/train:1. A name with no owner, like cuda, is looked up on Docker Hub as library/cuda.

Legion checks the image before it rents. If the image can't be used, the rent form says why. Through the API, call inspectImage first.

A public image needs nothing more. For a private one, save a registry credential first: see Private images.

Private images

Legion can run a private image from any registry that hands out pull tokens. That covers Docker Hub, GitHub's ghcr.io, GitLab, Quay, NVIDIA NGC, Harbor, Artifactory, Artifact Registry, Azure Container Registry and self-hosted registries with a token service. Your organization saves a registry credential: a username and a read-only token. Legion runs no registry for it and keeps no copy: the host pulls the image straight from your registry.

When the image you enter is private, the Registry credential section of the rent form says so. If one of your saved credentials fits the image, the section says Uses: acme on ghcr.io and you can press Change to pick another one for this rental. If none fits, press Add a credential:

  1. The form starts with the image you entered (Image to check). Legion reads the registry and the Path prefix from it, and the prefix can be edited. Leave it empty to use the credential for every image on the registry.

  2. Enter a Username and a Token. A Name is optional.

  3. Press Save credential. Legion checks that the credential can read the image before it saves anything.

  4. Press Rent.

You can also add one under Settings, then Registry credentials, which lists them all.

To give a container tokens or other values at run time, use secret environment variables rather than building them into the image.

Use a read-only token made only for Legion, so you can revoke it without touching anything else. What to enter depends on the registry:

Private images
RegistryUsernameToken
docker.ioYour Docker ID, not your email addressA personal access token with Read-only permission
ghcr.ioYour GitHub usernameA classic personal access token with only the read:packages scope. Fine-grained tokens don't work with ghcr.io
nvcr.io$oauthtoken, exactly as written (the form fills it in)An NGC API key
quay.ioA robot account's name, like acme+legionThe robot account's token, with Read access to the repository
GitLab (registry.gitlab.com)The username shown when you create a deploy tokenA deploy token with only the read_registry scope
Artifact Registry (*-docker.pkg.dev)_json_key_base64A service account key with the Artifact Registry Reader role, base64 encoded on one line
Azure (*.azurecr.io)The token name, or the application ID of a service principalA repository-scoped token, or a service principal secret with the AcrPull role. Don't use the admin user
Harbor and othersA robot account's name, like robot$project+legionThe robot account's secret, with pull permission only

For any other registry, enter the username and token its administrator gave you.

Several credentials, matched automatically

An organization can save up to 20 credentials, and several for one registry host. Each has a path prefix: the part of the image path it covers. A credential for ghcr.io with the prefix acme is used for ghcr.io/acme/model, and another for ghcr.io with the prefix other-org is used for that organization's images. An empty prefix covers every image on the host.

When you rent, Legion uses the credential whose host matches the image and whose prefix is the longest match. The rent form shows it as Uses: acme on ghcr.io, with the name you gave it, or the host and prefix when it has none. Change picks a different credential on the same host for this rental. A rental keeps the credential it started with.

Saving never replaces another credential. A second credential with the same host and prefix is refused, and the answer names the one that exists: replace its token instead.

Who can do what

Any member can rent with a saved credential. Adding one, replacing its token, renaming it and removing it need the registry.manage permission, which owners have. Everyone in the organization can see the list (name, host, prefix, username, who saved it, when it was last used), never a token.

Removing a credential is refused while a rental that may still pull with it exists. The answer names those rentals: stop or delete them, then remove it. Rentals already running keep running, and a rental that has to pull its image again needs its credential until it ends.

If the registry later refuses the credential, for example because the token was revoked, the rent form says so and offers to save a new token. A rental whose pull is refused fails with the reason. An organization can save 20 times an hour, including saves that fail.

What happens to the token

  • Legion keeps it encrypted and never shows it again, to anyone.

  • It's never sent to a host. When a host pulls your image, Legion exchanges the credential at the registry's own token service for a pull token for that one repository. The registry issues it and decides how long it lasts, and it is short-lived. It can read every tag in that repository, not only the image you rented.

  • The registry's token service is found when you save and pinned: the token is only ever sent there.

  • The image runs on the provider's machine, where the provider has full access. Treat what's in the image as visible to that provider, and don't build secrets into it.

Not supported yet

  • AWS ECR (*.dkr.ecr.*.amazonaws.com). An ECR password is a 12-hour token made from AWS keys. A host could only pull with a long-lived secret, which Legion never sends to a host. Push the image to a registry in the table above, or mirror it to one. Images on public.ecr.aws are public and need no credential.

  • Registries that only accept a username and password and have no token service, for the same reason.

  • Registries on an IP address, a port other than 443, or a name with a single label, and any address inside Legion's own network.

Through the API: createRegistryCredential, listRegistryCredentials, updateRegistryCredential, deleteRegistryCredential and detectRegistryCredential, which splits an image reference into host and prefix without saving anything. createRental takes an optional registry_credential_id to use a credential other than the matched one. The older putRegistrySignIn operations still work for a credential that covers a whole host and are deprecated. From a terminal, see legion registry.

What Legion adds

Any Linux image works. Legion adds its own SSH server and init process to your container, so SSH and the web terminal work whatever image you choose. Your image's ENTRYPOINT, CMD, USER and environment are kept.

If your image starts its own init system, such as systemd or s6, it runs beneath Legion's init.

When your process exits

If your image's own process exits, the rental stays up and SSH keeps working. The login message shows its exit status. Its last output is in /.legion/run/workload.log.

Shared memory

/dev/shm is half the rental's memory, between 1 GiB and 64 GiB.