Quick Start
While ComfyUI doesn’t provide official Docker images in the repository, you can easily create your own Dockerfile or use community images.Basic Dockerfile
Here’s a production-ready Dockerfile for ComfyUI:Dockerfile
Build and Run
The
--gpus all flag requires the NVIDIA Container Toolkit to be installed.Docker Compose Setup
For easier management, use Docker Compose:docker-compose.yml
Start the Service
Multi-Stage Build (Optimized)
For smaller image sizes, use a multi-stage build:Dockerfile.multistage
GPU Support
NVIDIA GPUs
Install the NVIDIA Container Toolkit:AMD GPUs (ROCm)
Dockerfile.rocm
CPU Only
Dockerfile.cpu
Volume Management
Persistent Storage
Create named volumes for better management:docker-compose.volumes.yml
Shared Model Storage
Share models between ComfyUI and other applications:extra_model_paths.yaml
docker-compose.shared.yml
Environment Variables
Configure ComfyUI behavior through environment variables:docker-compose.env.yml
Health Checks
Add health checks to ensure ComfyUI is running:docker-compose.health.yml
Reverse Proxy Setup
Nginx
nginx.conf
Traefik
docker-compose.traefik.yml
Production Best Practices
Resource Limits
Resource Limits
Set resource limits to prevent container from consuming all system resources:
Restart Policies
Restart Policies
Configure automatic restart on failure:
Logging
Logging
Configure logging drivers to prevent disk space issues:
Security
Security
Run as non-root user:
Scaling with Docker Swarm
docker-stack.yml
Kubernetes Deployment
For large-scale deployments, use Kubernetes:comfyui-deployment.yaml
Troubleshooting
GPU Not Detected
Permission Issues
Out of Memory
Slow Performance
Next Steps
Python Integration
Integrate ComfyUI into your applications
Headless Mode
Configure CLI options for production