- Wed 02 December 2026
- Systems
Running Containers on Slurm with Enroot and Pyxis
Many GPU clusters that run Slurm use two NVIDIA tools to run
containerized jobs. Enroot imports a Docker
image from a registry, converts it to a SquashFS file and starts an
unprivileged sandbox from that file. Pyxis is a Slurm plugin that
does these steps for each job step, so a single srun option
runs a command inside an image:
srun --container-image=nvcr.io/nvidia/pytorch:26.03-py3 python -c "import torch; print(torch.__version__)"This workflow differs from the two that most users bring to a cluster. Academic users tend to work on bare metal, with environment modules (Lmod) and conda environments, or with Apptainer (formerly Singularity) images. Software developers tend to use Docker, building and testing images locally and deploying them to Kubernetes. Enroot and Pyxis take Docker images as input but run them without a daemon, without root and with little isolation. The SquashFS files they produce are managed by hand, and where they live affects how fast a job starts.
Enroot
The Enroot
README describes the tool as “an enhanced unprivileged
chroot(1)”. It uses the same kernel namespaces as other
container runtimes, but by default it creates only a user namespace and
a mount namespace. PID, network, IPC and UTS namespaces are optional
ENROOT_UNSHARE_* settings. A process inside an Enroot
container sees the host’s network interfaces, processes and devices.
Only the root filesystem is separate. On an HPC cluster this is usually
the intent. A multi-node job needs the host’s InfiniBand or RoCE devices
and its shared filesystems, and the extra isolation of a Docker
container would get in the way of both.
Enroot works in three steps:
enroot import -o /path/to/nemo.sqsh docker://nvcr.io/nvidia/nemo:25.01
enroot create --name nemo /path/to/nemo.sqsh
enroot start nemo python -c "import nemo"import downloads the image layers from the registry and
writes a single SquashFS file, a compressed read-only filesystem image.
Without -o, the file is named after the image, for example
nvidia+nemo+25.01.sqsh. create unpacks the
SquashFS file into a root filesystem under
$ENROOT_DATA_PATH, and start runs a command
with that root filesystem. Registry credentials go in
$ENROOT_CONFIG_PATH/.credentials in netrc format. For NGC,
the import
documentation lists two entries, one for nvcr.io and
one for authn.nvidia.com.
Image references
Before version 4.0.0, released in October 2025, Enroot required a
# between the registry and the image name:
docker://nvcr.io#nvidia/nemo:25.01. A reference without the
#, such as docker://nvcr.io/nvidia/nemo:25.01,
was read as an image on Docker Hub. Since 4.0.0, Enroot treats the first
component of the path as a registry when it contains a dot or a colon,
so Docker-style references work as well. Clusters with an older Enroot
still need the # form. In an sbatch script,
the # has to be escaped as \# inside an
#SBATCH line, because Slurm reads an unescaped
# as the start of a comment.
Pyxis
Pyxis is a SPANK
plugin. It adds --container-* options to srun,
salloc and sbatch, and on each node it calls
Enroot to import, create and start the container before the task runs.
An interactive shell inside a CUDA image on one node with four GPUs:
srun -A <account> -p batch -N1 --gpus=4 --time=4:00:00 --pty \
--container-image=nvcr.io/nvidia/cuda:13.1.1-runtime-ubuntu24.04 /bin/bashThe options from the Pyxis README that most jobs use:
| Option | Effect |
|---|---|
--container-image |
A registry image or the path of a SquashFS file on the compute node’s filesystem |
--container-mounts=SRC:DST[,...] |
Bind mounts from the host, for datasets, code and checkpoints |
--container-workdir |
Working directory inside the container |
--container-name |
Keeps the unpacked container on the node after the step ends. A later step in the same job with the same name reuses it and skips the import |
--container-save=PATH |
Writes the container’s state to a SquashFS file when the step ends |
--container-writable |
Makes the container filesystem writable |
--container-remap-root |
Maps the user to root inside the container, which lets
apt and pip install into system paths. It
grants no extra permissions on the host |
--container-unshare=net,ipc,uts |
Creates separate network, IPC or UTS namespaces for the container |
Unless --container-mount-home or
--no-container-mount-home is given, the site’s Enroot
configuration (ENROOT_MOUNT_HOME) decides whether the home
directory is mounted. Exported host environment variables are set in the
container, but a value that the image already sets takes precedence.
SquashFS files and job start time
With a registry image, every node in the job imports the image when the step starts. Pyxis caches layers and shares them between users on a node, but a node without the layers in its cache downloads the full image, and every node still converts it. For a framework image of tens of gigabytes, this delays the start of every job, and an N-node job sends N downloads to the registry at once.
Passing a SquashFS path to --container-image skips the
download and the conversion. Each node reads the file from the shared
filesystem and unpacks it. The cost moves from job start to a one-time
import, and the user becomes responsible for where the file lives, which
version it holds and when to delete it.
How teams build and share images
The workflows below are listed from the most ad hoc to the most automated:
- A base image plus run-time installs. The job starts
from a public framework image, mounts the team’s code and runs
pip installin every job. No image is built, and every job repeats the installation and depends on the package index being reachable and unchanged. This is the workflow to avoid. - Saved SquashFS files. An interactive job starts
from a base image with
--container-remap-root --container-writable, installs the dependencies and ends with--container-save=/shared/team/env.sqsh. This is fast to produce, but the file records no build steps, so it is hard to reproduce or update. - Shared team images. One person maintains a few
SquashFS files on the shared filesystem, and the team points
--container-imageat them. This avoids duplicate files and gives everyone the same environment, but it needs a convention for names and versions. - A local Docker build and a registry. A developer
builds the image with a Dockerfile on a workstation, pushes it to a
registry such as GitLab’s container registry, and imports it on the
cluster with
enroot import. The Dockerfile records the build, and the same image runs locally and on the cluster. - CI-built images. A CI pipeline builds and pushes an image for each merge request or commit. Each image tag then corresponds to a commit, and a job can name the exact code it runs.
Workflows 4 and 5 still benefit from importing the image once into a SquashFS file on the shared filesystem, for the start-time reasons above.
References
If you found this useful, please cite this post using
Senthilkumar Gopal. (Dec 2026). Running Containers on Slurm with Enroot and Pyxis. sengopal.me. https://sengopal.me/posts/running-containers-on-slurm-with-enroot-and-pyxis
or
@article{gopal2026runningcontainers,
title = {Running Containers on Slurm with Enroot and Pyxis},
author = {Senthilkumar Gopal},
journal = {sengopal.me},
year = {2026},
month = {Dec},
url = {https://sengopal.me/posts/running-containers-on-slurm-with-enroot-and-pyxis}
}