• January 2, 2026

How to Deploy ComfyUI – AI Workflow Builder

How to Deploy ComfyUI – AI Workflow Builder

Host ComfyUI with Docker Compose and Traefik for secure, node-based AI image workflows.

ComfyUI is an open-source node-based interface for Stable Diffusion that enables complex image generation workflows. It provides a visual graph editor where users connect nodes to build custom pipelines for text-to-image, image-to-image, and inpainting tasks. ComfyUI supports advanced features like ControlNet, LoRA models, and custom sampling methods while offering efficient memory management for generating high-resolution images.

In this article, you will deploy ComfyUI using Docker Compose, configure persistent storage for models and outputs, and set up Traefik as a reverse proxy to securely access your ComfyUI instance.

Prerequisites

Before you begin, you need to:

  • Have access to an Ubuntu 24.04-based server as a non-root user with sudo privileges.
  • Install Docker and Docker Compose.
  • Configure a domain A record pointing to your server’s IP address (for example, comfyui.example.com).

Set Up the Directory Structure and Environment Variables

In this section, you prepare the required directory structure for ComfyUI and define environment variables in a .env file.

  1. Create the directory structure for ComfyUI.
    console
    $ mkdir -p ~/comfyui/{storage,models,output,input}

    These directories store different types of data:

    • storage: Contains ComfyUI application data, custom nodes, and cached files.
    • models: Contains Stable Diffusion checkpoints, LoRA files, and ControlNet models.
    • output: Stores generated images and workflow outputs.
    • input: Holds reference images for img2img and inpainting workflows.
  2. Navigate into the comfyui directory.
    console
    $ cd ~/comfyui
  3. Create a .env file.
    console
    $ nano .env

    Add the following variables:

    ini
    DOMAIN=comfyui.example.com
    LETSENCRYPT_EMAIL=admin@example.com

    Replace:

    • comfyui.example.com with your domain.
    • admin@example.com with your email.

    Save and close the file.

Deploy with Docker Compose

In this section, you create and deploy the Docker Compose stack that runs ComfyUI behind Traefik. Docker Compose manages both containers, applies the environment variables from your .env file, and automatically configures HTTPS routing through Traefik.

  1. Create a new Docker Compose manifest.
    console
    $ nano docker-compose.yaml
  2. Add the following content.
    yaml
    services:
      traefik:
        image: traefik:v3.6
        container_name: traefik
        command:
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.websecure.address=:443"
          - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
          - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
          - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
          - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
          - "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
          - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "letsencrypt:/letsencrypt"
          - "/var/run/docker.sock:/var/run/docker.sock:ro"
        restart: unless-stopped
    
      comfyui:
        image: yanwk/comfyui-boot:cpu
        container_name: comfyui
        hostname: comfyui
        environment:
          - CLI_ARGS=--listen --cpu
        expose:
          - "8188"
        volumes:
          - "./storage:/root"
          - "./models:/root/ComfyUI/models"
          - "./output:/root/ComfyUI/output"
          - "./input:/root/ComfyUI/input"
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.comfyui.rule=Host(`${DOMAIN}`)"
          - "traefik.http.routers.comfyui.entrypoints=websecure"
          - "traefik.http.routers.comfyui.tls.certresolver=letsencrypt"
          - "traefik.http.services.comfyui.loadbalancer.server.port=8188"
        restart: unless-stopped
    
    volumes:
      letsencrypt:

    Save and close the file.

    This manifest establishes:

    • services: Two containers deliver the image generation platform:
      • traefik: Processes incoming connections, provisions TLS certificates, and routes traffic to ComfyUI.
      • comfyui: Executes the Stable Diffusion backend and serves the node-based workflow editor.
    • image: ComfyUI CPU image includes the complete runtime environment for CPU-based inference.
    • environmentCLI_ARGS=--listen --cpu configures ComfyUI to accept connections from Traefik and forces CPU-only inference mode.
    • container_name: Consistent naming conventions streamline container management.
    • command (Traefik): Activates Docker integration, configures dual-port listeners (80/443), enforces protocol redirection, and enables Let’s Encrypt certificate automation.
    • ports (Traefik): Maps standard HTTP and HTTPS ports for external connectivity.
    • expose (ComfyUI): Opens port 8188 within the container network for Traefik access.
    • volumes:
      • Bind mounts (./storage./models./output./input) preserve application data, model files, and generated images across restarts.
      • Named volume letsencrypt retains certificate data through service updates.
      • Docker socket grants Traefik read-only access for container discovery.
    • labels (ComfyUI): Traefik routing directives that enable proxying, specify hostname matching, attach SSL certificates, and define the backend port.
    • restart: unless-stopped: Implements automatic recovery after failures or system reboots.
  3. Create and start the services.
    console
    $ docker compose up -d
  4. Verify that the services are running.
    console
    $ docker compose ps

    Output:

    NAME       IMAGE                       COMMAND                  SERVICE    CREATED          STATUS          PORTS
    comfyui    yanwk/comfyui-boot:cpu      "bash /runner-script…"   comfyui    36 seconds ago   Up 35 seconds   8188/tcp
    traefik    traefik:v3.6                "/entrypoint.sh --pr…"   traefik    36 seconds ago   Up 35 seconds   0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp

    Both containers are operational. ComfyUI processes image generation requests while Traefik manages connections on ports 80 and 443.

  5. View the logs of the services.
    console
    $ docker compose logs

    For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.

Access ComfyUI

This section shows how to access the ComfyUI interface and configure models for image generation workflows.

  1. Open the ComfyUI interface in your browser.
    https://comfyui.example.com
  2. The node-based workflow editor displays with a default text-to-image workflow. Explore the main interface components:
    • Canvas: The central workspace where you build and connect nodes.
    • Node Menu: Right-click the canvas to access available nodes for sampling, conditioning, and image processing.
    • Queue: The sidebar shows pending and completed generation tasks.
  3. To generate images, download Stable Diffusion model files (.safetensors or .ckpt) from sources like Civitai or Hugging Face and place them in the ~/comfyui/models/checkpoints directory.
  4. Build workflows by right-clicking the canvas to add nodes, then connect them by dragging from output to input sockets. Click Run to execute the workflow.

Conclusion

You have successfully deployed ComfyUI for AI image generation with HTTPS encryption. The Docker Compose configuration unites the Stable Diffusion interface with automated SSL management, while persistent volumes maintain your model library and generated artwork. Traefik handles certificate provisioning and secure request routing. Your ComfyUI instance is ready to execute complex generation workflows, experiment with various models and techniques, and produce high-quality AI-generated images through its intuitive node-based editor.

Leave a Reply

Your email address will not be published. Required fields are marked *