# Templates

> Official and custom templates — how to run your own Docker image on Meshive from a public or private registry, with its ports, environment variables, volume mounts and start command.

Source: https://docs.meshive.ai/documentation/templates/

Every pod starts from a **template**: a container image plus the settings it runs with — ports, environment variables, volume mounts and a start command. You pick a template when you create a pod, and you can still adjust its settings on the deploy screen.

| | Official templates | Custom templates |
| --- | --- | --- |
| **Made by** | Meshive | You, in your workspace |
| **Image** | Maintained by Meshive — frameworks, IDEs, inference servers, generative tools such as ComfyUI, databases and more | Any `linux/amd64` image from a public or private registry |
| **Who sees it** | Everyone | Members of the workspace that owns it |
| **Where** | The **Official** tab when you create a pod | The **Custom** tab when you create a pod, and **Resources › Template** |

To run your own image, create a custom template once and deploy pods from it as often as you like.

## Before you start

- **The image must be built for `linux/amd64`.** Multi-architecture images work as long as they include an `amd64` variant. An image built only for ARM (for example on an Apple Silicon Mac without `--platform linux/amd64`) can't be loaded.
- **Only workspace admins and billing members** can create, edit, rename or delete custom templates. Viewers can open them but not change them.
- **A private image needs a registry credential** — see [Private registries](#private-registries).

## Create a custom template

1. In the console, open **Resources › Template** and select **Add template**.
2. Enter a **template name** and, optionally, a description.
3. Enter the **image** reference, for example `docker.io/myorg/trainer:1.4` or `ghcr.io/myorg/app@sha256:…`. A tag or a digest both work; with neither, `latest` is used.
4. For a private image, choose its **registry auth**.
5. Select **Load image config**. Meshive reads the image's own settings and fills in the sections below. This step is required — a template can't be saved until the image has loaded.
6. Review and adjust **Endpoints**, **Environment variables**, **Volume mounts** and the **start command**.
7. Select **Submit**. The template appears in **Resources › Template** and in the **Custom** tab of the pod create flow.

### What Load image config reads

| From the image | Becomes |
| --- | --- |
| `ENV` | Environment variables |
| `EXPOSE` | Endpoints (ports) |
| `VOLUME` | Volume mounts |
| `ENTRYPOINT`, `CMD` | The image's start command, shown for reference |
| `WORKDIR` | The directory the start command runs in |

Anything the image doesn't declare you add yourself. A common case: an app that listens on a port without an `EXPOSE` line — add that port under **Endpoints**.

## Private registries

Add the credential once per workspace in **Settings › Credentials**, then choose it as the template's registry auth.

| Field | Value |
| --- | --- |
| **Name** | A label you'll recognize |
| **Registry server** | **Docker Hub**, **GitHub** (`ghcr.io`), **GitLab** (`registry.gitlab.com`), **Quay** (`quay.io`), or **Other** with the registry's host |
| **Username** | Your registry username |
| **Password** | A password or, preferably, an access token with read-only pull access |

The registry must be reachable from the public internet. Registries on a private network can't be used.

> **Tip:**
> Docker Hub limits how often an image can be pulled without signing in. If you deploy a popular public image often, adding a Docker Hub credential avoids **Registry Rate Limited** errors.

## Ports

Each endpoint has a **name** and a **container port** — the port your app listens on inside the container. Names and ports must be unique within a template.

| Access | Result |
| --- | --- |
| **Internal** | Reachable only from pods in the same workspace. No URL. |
| **Public** | Gets an HTTPS URL. As the template's author you choose whether it starts **locked** (workspace members and programs with an [access key](/documentation/endpoint-access-keys/)) or **unlocked** (anyone with the URL). |

See [Locked ports](/documentation/endpoint-access/) for how locking works and how to call a locked port from code.

## Environment variables

Each variable has a key and a value, and can be marked **secret** so its value is hidden in the console. Hidden means hidden from people looking at the console: the value is still set inside the container, on the machine that runs the Pod. Keys must be unique.

Meshive sets some variables itself. Keys starting with `MESHIVE_SYS_`, and `MESHIVE_RUN_AS_ROOT`, are reserved and refused with *Meshive sets this variable — rename this key*.

Values in a template are defaults. Whoever deploys a pod can change them on the deploy screen, or with `--env KEY=VALUE` in the [CLI](/sdk-cli/cli/pod-create-update/#meshive-pod-create).

## Volume mounts

A volume mount is a named path in the container where a [persistent volume](/storage/) should be attached — for example `/workspace` or `/data`. When you deploy, you connect a volume to each mount path. If you deploy with a mount path left unconnected, the deploy screen asks you to confirm first: files written there don't survive the pod being re-created.

Names and paths must be unique. System paths can't be used as mount paths:

| Not allowed | |
| --- | --- |
| `/`, `/proc`, `/sys`, `/boot`, `/bin`, `/sbin`, `/lib`, `/lib64` | Including everything under them |
| `/root`, `/usr`, `/etc`, `/dev` | The path itself (most paths under them are fine, for example `/root/.cache`) |
| `/usr/bin`, `/usr/sbin`, `/usr/lib`, `/usr/lib64`, `/usr/local` and system files such as `/etc/hosts` | Including everything under them |

Use paths such as `/workspace`, `/data` or `/home/<user>`.

## Start command

By default the pod runs the image's own `ENTRYPOINT` and `CMD`. **Overwrite commands** replaces them — useful for an image whose default command isn't what you want to run, or to do some setup first. The command can be up to 32,000 characters. To run several commands in order, see [How do I run several commands when a pod starts?](/getting-started/faq/)

> **Note:**
> When the start command exits, the container exits with it. To keep a pod up for interactive work, the command must keep running — for example a server, or `sleep infinity` after your setup steps.

## Deploy a pod from a template

**Console:** start creating a pod, open the **Custom** tab, pick your template, then choose the GPU or CPU, storage and settings as usual.

**CLI:** custom templates are created in the console; once one exists, find its ID and pass it to `pod-create`.

```bash
meshive templates --workspace <workspace> --type custom
meshive pod-create <workspace> <name> --template <id> --gpu "RTX 5090" --env MODEL_NAME=my-model
```

See [`meshive pod-create`](/sdk-cli/cli/pod-create-update/#meshive-pod-create) for every option, including how to change the template's ports and start command for one pod.

## Troubleshooting

| You might see | It means | Do |
| --- | --- | --- |
| **Invalid Image Reference** | The image field isn't a valid image reference — often a web URL pasted from a registry's site. | Use the pull reference, for example `ghcr.io/org/app:tag`. |
| **Loading Image Failed** — *Image not found* | The name, tag or digest doesn't exist, or the image is private and the registry hides it. | Check the reference. For a private image, choose its registry auth. |
| **Registry Credential Required** | The image is private and no credential was chosen. | Add one in **Settings › Credentials** and choose it. |
| **Authentication Failed** / **Access Denied** | The credential's username or password is wrong, or it can't read this repository. | Update the credential, or use a token with pull access to the repository. |
| **Registry Rate Limited** | The registry is limiting requests — usually Docker Hub without a credential. | Wait a few minutes, or add a Docker Hub credential. |
| **Registry Not Allowed** | The registry host points to a private network address. | Push the image to a registry reachable from the internet. |
| **Loading Image Failed** — *could not be read* | Often an image without a `linux/amd64` variant. | Rebuild with `docker buildx build --platform linux/amd64 …`. |
| Pod stays **creating** for a long time | A large image is still being pulled. | Wait; the [CLI](/sdk-cli/cli/pods/#meshive-transactions) shows pull progress. |
| Pod starts, then fails or keeps restarting | The start command exited. | Check the pod's logs, and keep the main process running. |
