This project provides a clean, reproducible, and isolated environment to run ComfyUI locally inside a Distrobox container built on Ubuntu 24.04.
Unlike configurations with multiple independent Docker stacks, this project manages only 1 consolidated instance of ComfyUI, following the official guidelines and leveraging the modern comfy-cli tool for installation and environment management.
- Ubuntu 24.04 Base: High compatibility with ML libraries and tools.
- Isolated Home Directory: Container state, pip caches, python virtual environments, and custom node checkouts are isolated under a local
.home/directory in this workspace, leaving your host system clean. - GPU Passthrough: Configured for NVIDIA GPU acceleration (CDI/CUDA), compatible with modern architectures including Nvidia Blackwell (RTX 5000 Series).
- Single Model Tree: Mounts a central models directory from the host to the container (e.g.,
/mnt/gigachad/comfyui/modelsor a local folder) mapped natively into ComfyUI's model loader. - Comfy CLI: Utilizes the modern, official CLI tool to automate ComfyUI install, upgrades, and launches.
- Pre-installed ComfyUI-Manager: Installs ComfyUI-Manager custom node out-of-the-box.
- Distrobox (version 1.8.0 or newer recommended) and Podman or Docker installed on the host.
- NVIDIA Proprietary Open Drivers (
nvidia-driver-560-openor similar compatible version) and the NVIDIA Container Toolkit (nvidia-container-toolkit) installed on the host.- For Blackwell (RTX 5000 / RTX 5060 Ti) GPUs, ensure you are running the
openkernel modules.
- For Blackwell (RTX 5000 / RTX 5060 Ti) GPUs, ensure you are running the
Copy the template .env.example to .env:
cp .env.example .envEdit .env to customize your:
PORT: Port where ComfyUI will run on the host (defaults to8188).MODELS_DIR: Absolute path to where your models (checkpoints, loras, vaes, etc.) are located on the host/NAS.
Create the container and trigger internal script setup (this will take a few minutes as it downloads packages and installs PyTorch with CUDA support):
make setupThis automates the following steps:
- Generates
distrobox.inimapping your custom.envpaths. - Builds the Distrobox container
comfyui-ubuntu. - Creates a virtual environment (
~/comfy-venv) inside the container. - Installs
comfy-cliand sets up ComfyUI optimized for Nvidia GPUs. - Populates
extra_model_paths.yamlto read from the mounted/mnt/comfyui-models. - Pre-installs
ComfyUI-Manager.
Start the server:
make startOpen your browser and navigate to http://localhost:8188 (or the custom port you configured).
All orchestration is managed via the Makefile in the root:
| Command | Action |
|---|---|
make create |
Creates the container without installing packages. |
make setup |
Provisions Python, ComfyUI, Comfy-CLI, and setup model mappings. |
make start or make run |
Starts the ComfyUI server. |
make enter |
Opens an interactive bash shell inside the container. |
make status |
Checks the registered distrobox containers. |
make stop |
Stops the running container. |
make destroy |
Destroys the container and deletes the generated distrobox.ini. |
make clean-all |
Destroys the container, deletes .home/ (cache and libs) and .env. |
distrobox-comfyui/
├── Makefile # Automation rules
├── distrobox.ini.template # Declarative Distrobox spec
├── setup.sh # Internal provisioning script (comfy-cli)
├── run.sh # Startup wrapper script
├── .env.example # Template for variables
├── .gitignore # Ignored local structures
├── .home/ # Isolated home directory (Git ignored)
└── models/ # Fallback local models folder (Git ignored)