Building a custom container image¶
When the default image is missing a
library or system package your work needs, don't reinstall it with %pip in
every notebook session — those installs disappear when your server restarts. Bake
the dependency into a custom container image instead. Anything in the image is
available automatically, every time, in both notebooks and batch jobs.
FLAME builds images for you. You push a
Dockerfile to a git
repository on the in-cluster Forgejo server, and
the cluster's CI system builds it and publishes the result to the cluster's
container registry (registry.flamecluster.io), ready for your workloads to
use. You don't need Docker installed anywhere, and the images are automatically
built for both CPU architectures used on FLAME
(amd64 and arm64).
This guide walks through the whole loop: write a Dockerfile, push it, find
the built image, and run it in JupyterHub and in a TrainJob.
What you'll need first
A FLAME workspace you're a member of. Your workspace comes with a matching Forgejo organization of the same name — that's where your image repositories live, and everything they build is private to your workspace.
Step 1: Sign in to Forgejo and set up git access¶
Go to https://git.flamecluster.io and sign in with Globus, the same way you sign in to JupyterHub (see Authentication). Your account is created automatically on first login, and you'll already be a member of your workspace's organization.
There's no Forgejo password, so to push over git you need to set up a credential. Either:
- SSH key (recommended): add your public key under Settings → SSH / GPG
Keys, then use
git@git.flamecluster.io:...clone URLs, or - Access token: create one under Settings → Applications, then use it as
the password for
https://git.flamecluster.io/...clone URLs.
Step 2: Write a Dockerfile¶
Create a new directory on your own machine (or in a notebook terminal) with a
file named Dockerfile. Start FROM one of the URCF base images and add what
you need:
FROM registry.flamecluster.io/urcf/jupyter-pytorch:2026.07.5
# System packages: switch to root to install, then back to the normal user
USER root
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
USER ubuntu
# Python packages: pip installs into the image's global environment
RUN pip install datasets==2.19.1 timm==1.0.27
There are two base images to choose from:
registry.flamecluster.io/urcf/jupyter-pytorch— the default JupyterHub notebook image (PyTorch + CUDA + JupyterLab + code-server). Start here if you'll use the image in notebooks, or in both notebooks and batch jobs.registry.flamecluster.io/urcf/pytorch— the same PyTorch + CUDA stack without the notebook tooling. A leaner choice for images used only in TrainJobs and batch work.
Browse the available tags on the urcf organization's packages page. See Base images for what each image includes and how releases are versioned.
Always start FROM a URCF base image
Starting FROM one of the URCF base images is the only supported way to
build a custom image. The base images carry everything FLAME expects of a
container — the jupyterhub Python package, the right user (UID 1000) and
home directory (/home/ubuntu), and SSH support
for ssh flame — so an image built on top of them just works. An image
built from scratch or from a third-party base is missing all of this, and
we can't help you debug the results.
SSH into custom images¶
ssh flame works by running a
small SSH server inside your notebook container. The URCF base images ship it,
so an image built FROM one of them keeps SSH working with nothing extra to
do. If ssh flame reports that your server does not accept SSH connections,
your image wasn't built from a URCF base — rebase it on one.
X11 forwarding (ssh -X flame) is allowed, but the base images don't include
the X11 tools it needs. To run graphical programs over SSH, install xauth
and the programs themselves in your image:
USER root
RUN apt-get update && apt-get install -y xauth x11-apps && rm -rf /var/lib/apt/lists/*
USER ubuntu
Your computer also needs an X server, such as XQuartz on macOS. Without
xauth in the image, ssh -X flame still connects but prints
X11 forwarding request failed.
Step 3: Push it¶
Create a git repository, commit the Dockerfile, and push it to a repo inside
your workspace's organization. You don't need to create the repository in the
web UI first — pushing to a new name creates it:
git init
git add Dockerfile
git commit -m "Custom image with ffmpeg and datasets"
git remote add origin git@git.flamecluster.io:my-workspace/my-image.git
git push -u origin main
(Replace my-workspace with your workspace name and my-image with whatever
you want the image to be called.)
Every push to the main branch triggers a build.
Following a build¶
The build's status shows up next to the commit in Forgejo: a yellow dot while
it runs, then a green check or a red cross. Click it to open the build in the
Tekton Dashboard, which shows each step of
the build and its logs, live while it runs. If a build fails, select the step
marked with a red cross; the reason is at the bottom of its log, usually a
line starting with ERROR: failed to solve.
Your workspace's builds run in a namespace of their own, named after the
workspace with -builds on the end, and every member of the workspace can see
them there. You can follow them with kubectl too:
kubectl get pipelineruns -n my-workspace-builds
kubectl logs -n my-workspace-builds <pod> --all-containers
(kubectl get pods -n my-workspace-builds lists a build's pods; the one whose
name contains build-and-push runs the build itself.)
Step 4: Find the built image¶
When the build finishes (a few minutes for a small Dockerfile — the base
images are large, so the first build takes the longest), the image appears on
your organization's packages page:
https://git.flamecluster.io/my-workspace/-/packages.
The image is named after the repository and tagged with the first 12 characters of the commit hash it was built from:
That's the full image reference you'll paste into JupyterHub or a TrainJob
below. You can also give a build a human-readable tag like v1 — see
Cutting a release.
Pull access is handled for you: workloads in your workspace's namespace are automatically authorized to pull images from your organization, with no credentials to configure. Images are private to your workspace.
Step 5: Use it in JupyterHub¶
On the JupyterHub start form, expand Advanced settings and paste the full
image reference into the Custom image field, then start your server as
usual. Your notebook session now runs your image — everything you baked in is
just there, no %pip install needed.
Leave the field blank to go back to the default image.
You can also save the image and start your server from the terminal:
ssh flamectl server config set --image registry.flamecluster.io/my-workspace/my-image:a1b2c3d4e5f6
ssh flamectl server start
ssh flame
The setting applies when the server next starts. To use the default image
again, run ssh flamectl server config set --image none and restart your server.
Step 6: Use it in a TrainJob¶
If you're submitting TrainJobs with the Kubeflow Train SDK
(as in the batch training guide),
pass the image reference to CustomTrainer:
job_name = client.train(
runtime="torch-rtxa6000",
trainer=CustomTrainer(
func=launch,
image="registry.flamecluster.io/my-workspace/my-image:a1b2c3d4e5f6",
resources_per_node={"cpu": 8, "memory": "32Gi", "gpu": 1},
),
)
If you write TrainJob YAML directly, the same setting is spec.trainer.image.
Building several images from one repository¶
If one repository needs to produce more than one image — a CPU and a GPU
variant, say, or a shared base plus the images derived from it — add a
docker-bake.hcl at the repository root
instead of a Dockerfile. The CI system builds every target it declares, in
parallel, and publishes each one as its own package. When a repository has both,
the bake file wins.
Two variables are set for you, so a bake file doesn't have to hardcode hostnames or tags:
REGISTRY— where your images belong: the cluster registry followed by the namespace of the repository being built (for a repo atmy-group/images, that's<registry>/my-group)SHORT_SHA— the first 12 characters of the commit being built
Declare both, then tag every target as ${REGISTRY}/<image>:${SHORT_SHA}:
variable "REGISTRY" {}
variable "SHORT_SHA" {}
group "default" {
targets = ["trainer", "preprocess"]
}
target "trainer" {
dockerfile = "Dockerfile.trainer"
tags = ["${REGISTRY}/trainer:${SHORT_SHA}"]
}
target "preprocess" {
dockerfile = "Dockerfile.preprocess"
tags = ["${REGISTRY}/preprocess:${SHORT_SHA}"]
}
Three rules the build enforces:
- A
defaultgroup is required. The build runs plaindocker buildx bake, which builds thedefaultgroup; without one it stops withfailed to find target default. List there whichever targets you want published — a target that only exists to be consumed by another through atarget:context doesn't need to be in it. - Every tag must start with
${REGISTRY}/. Images publish under your own namespace and nowhere else; a tag naming somewhere else fails the build before anything is pushed. - Every target is built for
amd64andarm64. You don't need aplatformsfield, and one that narrows the list is overridden — anamd64-only image would not run on the GPU nodes.
Building one image from several targets works as you'd expect: a target
referenced through contexts = { base = "target:base" } is built first and
passed straight to the image that consumes it, without a round trip through
the registry.
Cutting a release¶
Every push to main publishes images tagged with the commit's short hash —
immutable, but not a name anyone wants to type. A release gives those exact
images a second, human-readable name, and it's driven from git:
Within a minute, <registry>/<your-namespace>/<image>:2026.06 points at the
same image as ...:<short-sha> — the same digest, the same bits that were
built and tested. Tagging an already-built commit rebuilds nothing, so a
release cannot differ from what you verified.
You don't have to wait for a build before tagging. Commit, tag, and push it all at once if you like:
The cluster builds the commit once and gives the result both names. The same holds for tagging a commit that was never built — an old commit, or one that wasn't the tip when you pushed: it gets built now, then tagged. Tagging always ends with the images existing under the name you chose.
Three things to know:
- The git tag becomes the image tag, verbatim. Tag
2026.06, notv2026.06, unless you want avin your image tags. A tag containing characters an image tag can't hold — a/, for instance — is skipped, and the build says so. - A released tag never moves. Moving a git tag that's already published as
an image fails the build. Pods pinned to
2026.06keep resolving to the image you released, permanently; if you need different bits, cut a new tag. - Several tags on one commit all get applied.
2026.06andstableon the same commit produce both image tags from a single build.