Skip to content

Conversation

@bbergeron0
Copy link

@bbergeron0 bbergeron0 commented Aug 12, 2025

Description

Introduce a Docker stack to run ComfyUI inside a container. This PR attempts to keep everything minimal, documented, and easy to maintain. I'm also committed to provide maintenance support regarding the Docker stack, and I've added my name to CODEOWNER to assist in future PR touching the Docker stack (it look likes CODEOWNERS was purged upstream to only include the two project admins, so I'll let the owners suggest how I can help them instead).

Features

  • All of ComfyUI's features
  • File ownership synchronization between the host and the ComfyUI containers
  • Automatic installation of ComfyUI and custom nodes dependencies
  • Allow defining additional python and system dependencies in case some custom node packs don't provide (or provide incomplete) requirement files
  • Support for ComfyUI manager
  • Support for mounting and persisting models, custom nodes, and user-generated data
  • Support for hardware acceleration (See "Testing" section bellow)
  • Podman support

Anti-Features

These are things this PR will not introduce unless explicitly requested by code owners. These anti-features are listed to keep the Docker stack minimal and unopinionated:

  • Anything ComfyUI or the ComfyUI Manager already provides in some capacity. This includes building-in, downloading, or managing models, custom nodes, or workflows.
  • Support for hardware or use cases not natively supported by ComfyUI
  • Infrastructure to publish Docker images on Docker Hub. I think it would be better to start by merging just a local Docker stack, and then add Docker Hub infra in another PR.
  • New features

TL;DR: This is Docker support and nothing more, with minimal maintenance costs. Users who want more from ComfyUI should look at the alternative projects listed at the end.

Motivation

While ComfyUI does well in terms of security and monitoring, we cannot catch everything, and the last line of defense should be to avoid running arbitrary software like custom node packs on host machines, hence why I propose offering a Docker image.

Furthermore, the need for an official ComfyUI Docker image (or at least some form of Docker compatibility) has been expressed multiple times, as evidenced by various issues and discussions. This demand is further demonstrated by other forks, repositories, and pull requests with similar goals to this one.

Known issues

  • Users can't persistently update ComfyUI from within the container because ComfyUI's installation directory is not mapped to a volume and does not persist across container reboots. This renders features like ComfyUI Manager's software update feature useless.
  • I recognize that several users have already created ad-hoc Dockerfiles for ComfyUI inside their repositories, so there might be merge conflicts on their end.
  • docker-compose.yaml is both a tracked and a user-editable file. Cautiousness will be required when committing.

Testing

HELP NEEDED: I don't have AMD hardware to test this image, so if anyone could assist with testing on AMD systems, I am willing to integrate AMD support before merging. Also, I only have one SD-capable computer, so contributions for broader testing would be appreciated.

Please read the "Running with Docker" section in README.md before testing. When commenting, please mention:

  • Your Operating System (If on Windows, mention your WSL distro)
  • Your Podman/Docker version
  • Your GPU
  • Your cloud computing environment, if applicable
  • Any changes you made to the configuration or the code
  • If you've encountered any error or warning, copy/paste the message and tell me whether it happened at buildtime or at runtime

Tested

  • OS: Gentoo, Ubuntu 24, RHEL9, Debian 13, Windows 11, WSL
  • Engines: Docker (Buildkit), Docker (Legacy), Podman
  • Hardware: RTX 3060, RTX 3070 Ti, RTX 2060
  • Features: ComfyUI Manager, custom nodes, custom pip dependencies & custom system dependencies

I've been daily-driving this setup since before that PR so I can attest that all the ComfyUI features (at least those that I've used so far) are operational.

Alternatives

Pull Requests

This PR competes with three others that I know of:

  • docker #530, which is two years old, offers fewer features, and is less documented in my opinion.
  • Dockerfile and automatic generation of images via GitHub Actions #1469, which is also old and less feature-rich, but importantly introduces GitHub Actions, which I believe would increase maintenance costs unnecessarily. If we eventually want to use Docker actions to publish ComfyUI images, I believe it would be wiser to start with the smaller step of distributing a local setup, then work, test, and debug our way toward GitHub Actions incrementally.
  • add docker config file #6993, which appears to be a potential supply chain attack.

Projects

Other projects that combine ComfyUI and Docker:

  • akitaonrails/ComfyUI-Docker-CUDA-preloaded Which is a collection of scripts and configuration files to build, run and maintain a ComfyUI image. Also offers a model downloader.
  • YanWenKun/ComfyUI-Docker Which introduce docker support and publish a few image variants on Docker Hub. Come with ComfyUI manager and a few models and custom node packs built-in for certain images.

@Ambrosiussen
Copy link

Thanks for making this PR. I'm going to give this a try on Win11 with a RTX4090.
I think it would be good to also modify the README.md in this PR so people without prior docker experience know how to run this :)

@Ambrosiussen
Copy link

Tried your latest changes - entrypoint.sh is not mounted in the container. So following your README steps 1:1 results in an error.

 ✔ Network comfyui_default  Created                                                                                0.0s
 ✔ Container comfyui        Created                                                                                8.2s
Attaching to comfyui
comfyui  | exec ./entrypoint.sh: no such file or directory```

@bbergeron0
Copy link
Author

bbergeron0 commented Aug 13, 2025

Tried your latest changes - entrypoint.sh is not mounted in the container. So following your README steps 1:1 results in an error.

 ✔ Network comfyui_default  Created                                                                                0.0s
 ✔ Container comfyui        Created                                                                                8.2s
Attaching to comfyui
comfyui  | exec ./entrypoint.sh: no such file or directory```

@Ambrosiussen That's strange; the image shouldn't have even completed its build if entrypoint.sh wasn't copied properly. Could you add these lines at the bottom of the Dockerfile, remove the "command" field in docker-compose.yaml, and share the new output?

ENTRYPOINT []
CMD pwd; ls -la

edit:
docker compose build output would help too. Thanks in advance!

@Ambrosiussen
Copy link

Okay so I tried a couple things:

  1. Did what you suggested:
comfyui exited with code 0(base) PS H:\Github\ComfyUI> docker compose up
[+] Running 1/1
 ✔ Container comfyui  Recreated                                                                                    1.4s
Attaching to comfyui
comfyui  | /comfyui
comfyui  | total 452
comfyui  | drwxr-xr-x  1 comfyui comfyui   4096 Aug 14 08:15 .
comfyui  | drwxr-xr-x  1 root    root      4096 Aug 14 08:15 ..
comfyui  | drwxr-xr-x  5 root    root      4096 Aug 13 11:17 .ci
comfyui  | -rwxr-xr-x  1 root    root       715 Aug 13 18:44 .dockerignore
comfyui  | drwxr-xr-x  7 root    root      4096 Aug 13 21:19 .git
comfyui  | -rwxr-xr-x  1 root    root       115 Aug 13 11:17 .gitattributes
comfyui  | drwxr-xr-x  4 root    root      4096 Aug 13 11:17 .github
comfyui  | -rwxr-xr-x  1 root    root       478 Aug 13 18:44 .gitignore
comfyui  | drwxr-xr-x  6 comfyui comfyui   4096 Aug 13 19:01 .venv
comfyui  | -rwxr-xr-x  1 root    root      1536 Aug 13 11:17 CODEOWNERS
comfyui  | -rwxr-xr-x  1 root    root      1923 Aug 13 11:17 CONTRIBUTING.md
comfyui  | -rwxr-xr-x  1 root    root      2899 Aug 13 21:19 Dockerfile
comfyui  | -rwxr-xr-x  1 root    root     35823 Aug 13 11:17 LICENSE
comfyui  | -rwxr-xr-x  1 root    root     27759 Aug 13 18:44 README.md
comfyui  | -rwxr-xr-x  1 root    root      3314 Aug 13 11:17 alembic.ini
comfyui  | drwxr-xr-x  2 root    root      4096 Aug 13 11:17 alembic_db
comfyui  | drwxr-xr-x  5 root    root      4096 Aug 13 11:17 api_server
comfyui  | drwxr-xr-x  3 root    root      4096 Aug 13 11:17 app
comfyui  | drwxr-xr-x 13 root    root      4096 Aug 13 18:44 comfy
comfyui  | drwxr-xr-x 10 root    root      4096 Aug 13 11:17 comfy_api
comfyui  | drwxr-xr-x  4 root    root      4096 Aug 13 11:17 comfy_api_nodes
comfyui  | drwxr-xr-x  2 root    root      4096 Aug 13 11:17 comfy_config
comfyui  | drwxr-xr-x  2 root    root      4096 Aug 13 11:17 comfy_execution
comfyui  | drwxr-xr-x  3 root    root      4096 Aug 13 18:44 comfy_extras
comfyui  | -rwxr-xr-x  1 root    root       131 Aug 13 18:44 comfyui_version.py
comfyui  | -rwxr-xr-x  1 root    root      3665 Aug 13 11:17 cuda_malloc.py
comfyui  | drwxrwxrwx  1 root    root      4096 Aug 13 19:07 custom_nodes
comfyui  | -rwxr-xr-x  1 root    root      1470 Aug 13 21:19 docker-compose.yml
comfyui  | -rwxrwxrwx  1 root    root      2772 Aug 13 18:44 entrypoint.sh
comfyui  | -rwxr-xr-x  1 root    root     52864 Aug 13 11:17 execution.py
comfyui  | -rwxr-xr-x  1 root    root      1527 Aug 13 11:17 extra_model_paths.yaml.example
comfyui  | -rwxr-xr-x  1 root    root     16332 Aug 13 11:17 folder_paths.py
comfyui  | -rwxr-xr-x  1 root    root       383 Aug 13 11:17 hook_breaker_ac10a0.py
comfyui  | lrwxrwxrwx  1 comfyui comfyui     11 Aug 13 21:43 input -> /data/input
comfyui  | -rwxr-xr-x  1 root    root      4457 Aug 13 11:17 latent_preview.py
comfyui  | -rwxr-xr-x  1 root    root     15035 Aug 13 11:17 main.py
comfyui  | drwxrwxrwx  1 root    root      4096 Aug 13 11:17 models
comfyui  | -rwxr-xr-x  1 root    root      1296 Aug 13 11:17 new_updater.py
comfyui  | -rwxr-xr-x  1 root    root      1744 Aug 13 11:17 node_helpers.py
comfyui  | -rwxr-xr-x  1 root    root    100720 Aug 13 11:17 nodes.py
comfyui  | lrwxrwxrwx  1 comfyui comfyui     12 Aug 13 21:43 output -> /data/output
comfyui  | -rwxr-xr-x  1 root    root       136 Aug 13 11:17 protocol.py
comfyui  | -rwxr-xr-x  1 root    root       702 Aug 13 18:44 pyproject.toml
comfyui  | -rwxr-xr-x  1 root    root       236 Aug 13 11:17 pytest.ini
comfyui  | -rwxr-xr-x  1 root    root       450 Aug 13 18:44 requirements.txt
comfyui  | drwxr-xr-x  2 root    root      4096 Aug 13 11:17 script_examples
comfyui  | -rwxr-xr-x  1 root    root     42678 Aug 13 11:17 server.py
comfyui  | lrwxrwxrwx  1 comfyui comfyui     10 Aug 13 21:43 temp -> /data/temp
comfyui  | drwxr-xr-x  4 root    root      4096 Aug 13 11:17 tests
comfyui  | drwxr-xr-x 12 root    root      4096 Aug 13 11:17 tests-unit
comfyui  | lrwxrwxrwx  1 comfyui comfyui     10 Aug 13 21:43 user -> /data/user
comfyui  | drwxr-xr-x  2 root    root      4096 Aug 13 11:17 utils
comfyui exited with code 0
  1. Changed the command in compose:
    from command: /comfyui/entrypoint.sh to command: /bin/bash /comfyui/entrypoint.sh. Then it runs entrypoint.

  2. You will want to add -u at the top of the bash script, so the line endings are correctly interpreted on Windows (This is only a problem for people who clone your PR, not you locally since your IDE already knows whats up):
    #!/bin/sh -u (Even better, change the .gitattributes for that file. Simply add *.sh text eol=lf
    Otherwise you run into:

(base) PS H:\Github\ComfyUI> docker compose up
[+] Running 1/1
 ✔ Container comfyui  Recreated                                                                                    0.2s
Attaching to comfyui
comfyui  | /comfyui/entrypoint.sh: line 2: $'\r': command not found
comfyui  | /comfyui/entrypoint.sh: line 8: $'\r': command not found
: invalid optionyui/entrypoint.sh: line 9: set: -
comfyui  | set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
comfyui  | /comfyui/entrypoint.sh: line 10: $'\r': command not found
comfyui  | /comfyui/entrypoint.sh: line 13: $'\r': command not found
comfyui  | /comfyui/entrypoint.sh: line 36: syntax error near unexpected token `$'do\r''
'omfyui  | /comfyui/entrypoint.sh: line 36: `for dev in /dev/nvidia*; do
comfyui exited with code 2
  1. Once that is fixed, entrypoint runs into:
(base) PS H:\Github\ComfyUI> docker compose up
Attaching to comfyui
comfyui  | [entrypoint] Setting user UID and GID...
comfyui  | [entrypoint] Changing directory ownership...
comfyui  | [entrypoint] Adding user to GPU device groups...
comfyui  | ls: cannot access '/dev/nvidia*': No such file or directory
comfyui  | [entrypoint] Installing new python dependencies, this might take a while...
comfyui  | [entrypoint] Running command
comfyui exited with code 0

@bbergeron0
Copy link
Author

I believe I figured it out. The error message exec ./entrypoint.sh: no such file or directory is misleading because entrypoint.sh does exist -- but its interpreter does not. With correct LF line endings, the interpreter is /bin/sh. However, when the file is checked out with CRLF endings, the interpreter path becomes /bin/sh\r, which explains why it works when you explicitly run it with /bin/bash /comfyui/entrypoint.sh.

Theoretically, adding the .gitattributes rule you mentioned should fix the issue.

I’ll push a fix soon. After that, you can run:

git pull
git checkout -- entrypoint.sh
docker compose build
docker compose up

@bbergeron0
Copy link
Author

What’s catching my attention now is the message: ls: cannot access '/dev/nvidia*': No such file or directory. Does this error also occur after applying the previous fix?

@yt-koike
Copy link

Hello, I'm @yt-koike, the starter of PR named Please publish Docker image with GitHub workflow.

I appreciate @bbergeron0 and @Ambrosiussen s' good job and I am willing to help you all!
I built and run the Docker container with your code and it worked marvelously on my PC with NVIDIA GeForce RTX 3070 Ti and CUDA 12.8 installed.

As my first contribution to this PR, I make some little suggestions as follows to make the code better.

  1. Renaming docker-compose.yml to compose.yaml

Docker officially says compose file should be named as compose.yaml in the Docker manual so please consider renaming the file. Of course, you can leave it if you value the backwards compatibility of earlier Docker more than that.

  1. Shortening the starter command

As you possibly know, the following commands can be shortened as docker compose up --build.

docker compose build
docker compose up

If the user does not modify the code at all and there's no need to build the image on every start, docker compose up would single-handedly do the job.

Thank you :)

@Ambrosiussen
Copy link

Ambrosiussen commented Aug 24, 2025

Just to provide my update - latest version of the PR works well!
I still get the same nvidia error, but compute works just fine.

EDIT: There is actually one change I would propose, as this is something you have to do for custom nodes, workflows (user scene files) and python venvs to work.

In the compose under volumes, you should just mount the entire comfy folder to the container.
Easiest is like this:
.:- .:/comfyui:rw

@bbergeron0
Copy link
Author

bbergeron0 commented Aug 24, 2025

Hi @yt-koike, thanks for your support! I'll add your hardware to the "testing" section of my PR. Could you also provide your OS? (I assume "PC" implies Windows 11, but I just want to be sure.)

  1. Renaming docker-compose.yml to compose.yaml

I've never seen a compose.yaml file before, but since that's the official recommendation, I agree with renaming it.

  1. Shortening the starter command

I'm planning on improving the documentation, so I'll see whether I shorten it for convenience or expand it for clarity and explanation.

@Ambrosiussen Thanks for the feedback. If I understand correctly, you're still seeing the ls: cannot access '/dev/nvidia*': No such file or directory error message, but hardware acceleration (CUDA, compute, etc.) still works anyway? I'm a bit confused because this error message shouldn't appear, and if it does, ComfyUI normally shouldn't launch or work. Could you try again after reverting your local changes to Dockerfile, docker-compose.yaml, and entrypoint.sh (if any), and flushing the previous volumes with docker compose down -v? Also, what's your Docker version?

In the compose under volumes, you should just mount the entire comfy folder to the container.

The Dockerfile already creates persistent volumes for user-generated data (input, output, temp, user), the virtual environment, custom nodes, models, and the ComfyUI user. The volumes worth mounting are documented inside docker-compose.yaml:

volumes:
  # Share custom nodes and models with the container.
  - ./custom_nodes:/comfyui/custom_nodes
  - ./models:/comfyui/models
  # Optional: mount the user data directory.
  #- data:/data/

I thought about it previously, but I decided against it. Some parts of the ComfyUI folders are meant to be immutable (i.e. the code), and unexpected behavior can occur if these files get overwritten and fall out of sync with the image after an update. It's also a security decision: the less data malicious custom node packs can persistently modify, the easier they are to contain. This is why I start by persisting the minimum possible, though I concede this comes at the cost of some convenience.

Maybe users would prefer to have everything mutable inside a single mountable "/data" folders?

@bbergeron0 bbergeron0 force-pushed the master branch 2 times, most recently from 20be04f to d343a7f Compare August 25, 2025 01:35
@yt-koike
Copy link

yt-koike commented Aug 25, 2025

Could you also provide your OS?

Sure, it's Ubuntu 24.04.3 LTS. I have my best GPU in that machine because Linux offers a very customable environment for developing.

I also have another computer which has Windows 11 and a NVIDIA GPU in, so let me check if ComfyUI works on it.

@icsy7867
Copy link

icsy7867 commented Aug 25, 2025

Trying to build using podman on RHEL9.

I got an error trying to build the dockerfile due to permissions on requirements.txt. I had to switch to root, chown it and switch back:

COPY requirements.txt ./
USER root
RUN chown comfyui requirements.txt
USER comfyui

This would probably be cleaner to add all of the files as root, and then chown them all to comfyui.

And...
in the Dockerfile, trying to create a symlink to the current directory fails because the folders already exist. I had to remove them when building via podman on RHEL9

COPY . .
RUN rm -rf /data/input && rm -rf /data/output
RUN ln -sf /data/* .

Also, on FIPS enabled system, this line will cause an issue in the requirements.txt file. The newest versions have an issue with fips.

av>=14.2.0

If you set this to 14.2.0 or 14.1.0 I believe it should work.

@bbergeron0
Copy link
Author

Hi @icsy7867, thanks for the feedback. Podman and non-BuildKit builds aren’t part of my goals, but I’ll see what I can do. After a few tweaks, I managed to build the image using both Podman and the legacy builder.

I got an error trying to build the Dockerfile due to permissions on requirements.txt.

Could you please pull the latest changes and try again? If the error persists, could you share the full error message?

In the Dockerfile, trying to create a symlink to the current directory fails because the folders already exist.

This shouldn’t happen given the .dockerignore file. Could you re-try and, if it still fails, share the error message, your Podman/Compose/Docker version along with the exact command you used?

Also, on FIPS-enabled systems, this line will cause an issue in the requirements.txt file. The newest versions have an issue with FIPS.

Unless this issue occurs specifically inside the Docker image, addressing it would be outside the scope of this PR. It might be better to open an issue in the tracker or raise it on Discord. I’m not familiar with FIPS, and I’d prefer not to make changes that affect the main developers' code or dependencies.

@icsy7867
Copy link

Hi @icsy7867, thanks for the feedback. Podman and non-BuildKit builds aren’t part of my goals, but I’ll see what I can do. After a few tweaks, I managed to build the image using both Podman and the legacy builder.

I got an error trying to build the Dockerfile due to permissions on requirements.txt.

Could you please pull the latest changes and try again? If the error persists, could you share the full error message?

In the Dockerfile, trying to create a symlink to the current directory fails because the folders already exist.

This shouldn’t happen given the .dockerignore file. Could you re-try and, if it still fails, share the error message, your Podman/Compose/Docker version along with the exact command you used?

Also, on FIPS-enabled systems, this line will cause an issue in the requirements.txt file. The newest versions have an issue with FIPS.

Unless this issue occurs specifically inside the Docker image, addressing it would be outside the scope of this PR. It might be better to open an issue in the tracker or raise it on Discord. I’m not familiar with FIPS, and I’d prefer not to make changes that affect the main developers' code or dependencies.

Fair enough. But FIPS breaking will prevent this from running on anything enterprise. But perhaps that should be a different PR.

open-webui/open-webui#15720

Same thing here. Basically using AV < 15.0.0 should work fine.

Ill try and pull and rebuild soon!

@yt-koike
Copy link

By the way, why don't we ask YanWenKun for help? The comfyui-docker repo has 1k stars and the dockerhub repo has 100k+ in total.

@yt-koike
Copy link

yt-koike commented Sep 14, 2025

@bbergeron0 I shall create an issue on the repo to call YanWenKun here if you don't mind.

@bbergeron0
Copy link
Author

@yt-koike I don't mind. His expertise with Docker and ComfyUI would be greatly appreciated. Instead of opening an issue, you could try DMing or emailing him first?

@YanWenKun
Copy link
Contributor

YanWenKun commented Sep 16, 2025

Hi there! Thanks for inviting me! @yt-koike

Your code looks well-thought-out, clean, and neat. 👍 @bbergeron0

A few points I'd like to address:

  1. You may want to mount these folders separately, since they store models:
~/.cache/huggingface/hub
~/.cache/torch/hub
  1. I noticed you mentioned ComfyUI-Manager, you might want to bundle or install it as well.

  2. As Please publish Docker image with GitHub workflow #9363 requested, if you want to build and upload images to Docker Hub, you need:

  • Create a Docker Hub account
  • Create an access token of the Docker Hub account
  • Configure the user name and access token as secrets of this GitHub repository (or you may want to start a new repo). GitHub Docs
  • Add a GitHub Actions workflow file under .github/workflows, example:
name: Publish Docker image to Docker Hub

on: 
  workflow_dispatch: # Can be manually triggered
  release: 
    types: [ published ] # Triggered when a new release (or pre-release) is published

jobs:

  build-publish:
    environment: Publish to Docker Hub
    runs-on: ubuntu-latest
    steps:
      -
        name: Maximize build disk space # Optional, can be removed if runner disk space is sufficient
        uses: easimon/maximize-build-space@master
        with:
          overprovision-lvm: 'true'
          remove-android: 'true'
          remove-dotnet: 'true'
          remove-haskell: 'true'
          remove-codeql: 'true'
          remove-docker-images: 'true'
          swap-size-mb: 512
      -
        name: Get current git tag
        id: tag
        run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
      -
        name: Git checkout
        uses: actions/checkout@v5
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      -
        name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_ACCESSTOKEN }}
      -
        name: Build and push Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: Dockerfile
          tags:  |
            comfyui/comfyui-cuda:latest
            comfyui/comfyui-cuda:${{ steps.tag.outputs.tag }}
          push: true

Also, just a note: ComfyUI-Docker was originally created to deal with upgradability and Dependency Hell (caused by Custom Nodes). Because of that, its design may sometimes look tricky or even a bit anti-pattern. I'd be happy to explain any part of the code if you'd like.

(And… the recent image tags aren't documented yet — sorry about that! I still have a few more images to add.)

@yt-koike
Copy link

yt-koike commented Sep 16, 2025

@YanWenKun Thank you very much for coming! I'm very happy to see you sharing helpful advises here!

@bbergeron0
Copy link
Author

Hi @YanWenKun, thanks for the review, I appreciate it! I have a few questions I'd like to ask:

You may want to mount these folders separately, since they store models

Currently, these folders are persisted as part of the /home/comfyui volume, but that volume isn’t mounted on the host by compose.yaml. Do you think that’s sufficient for storage and management?

Also, just a note: ComfyUI-Docker was originally created to deal with upgradability and Dependency Hell

How does ComfyUI-Docker address dependency management, especially regarding CUDA dependencies? So far, my impression has been that installing any requirements.txt from ComfyUI and custom node packs, along with a few extra system dependencies, should be enough to cover everything (including CUDA packages, which are pulled in by the PyTorch wheel). However, I see that ComfyUI-Docker and many other projects manually download CUDA, and that different images install different CUDA versions. What’s the reason for this approach?

@YanWenKun
Copy link
Contributor

Currently, these folders are persisted as part of the /home/comfyui volume, but that volume isn’t mounted on the host by compose.yaml. Do you think that’s sufficient for storage and management?

Yes, it works fine for all ComfyUI Example Workflows, since all models are properly saved under ComfyUI/models/ according to convention.

However, some Custom Nodes rely on HuggingFace Hub or HuggingFace Diffusers to download/load models, as this approach is straightforward and intuitive for researchers in their daily work. For example, ComfyUI-3D-Pack can download more than 100 GB of models into ~/.cache/huggingface/hub. That’s why it’s worth persisting this folder separately.

Of course, there’s an alternative: you can redirect these folders by setting environment variables, e.g.:

HF_HUB_CACHE=/comfyui/models/huggingface_hub
TORCH_HOME=/comfyui/models/torch_home

(Note: there’s no equivalent env var for TORCH_HUB.)

As a side note, HuggingFace Hub uses symbolic links to reduce storage size. This should work fine (even on WSL2), since it only relies on basic functionality and relative link paths.

@YanWenKun
Copy link
Contributor

How does ComfyUI-Docker address dependency management, especially regarding CUDA dependencies? So far, my impression has been that installing any requirements.txt from ComfyUI and custom node packs, along with a few extra system dependencies, should be enough to cover everything (including CUDA packages, which are pulled in by the PyTorch wheel). However, I see that ComfyUI-Docker and many other projects manually download CUDA, and that different images install different CUDA versions. What’s the reason for this approach?

The PyTorch release on PyPI follows the stable branch (currently cu128; the next one will also be cu128).
That’s perfectly fine for running the latest ComfyUI with all Example Workflows.

However, when Blackwell (RTX 50 series) was released, the stable branch of PyTorch 2.7 was cu126, which did not work on RTX 50 series. In that case, users needed a cu128 build.

In addition, some Python packages require manual version specification.

CUDA version–sensitive packages:

PyTorch version–sensitive packages:

CUDA + PyTorch version–sensitive packages:

As you can see, in some cases it’s necessary to lock down the versions, particularly in the AI-3D field — where packages are notoriously difficult to install, you can’t just let it upgrade whenever a new stable release comes out. But nowadays, 3D local inferencing is, to be honest, less impressive compared to online APIs.

That said, for a minimal Docker image that only needs to run ComfyUI, I think it’s fine to leave it up to PIP.

@A-Temur
Copy link

A-Temur commented Sep 22, 2025

as an AMD user, i have used a custom docker setup, which worked very well:

  1. I have created a folder on my host and git cloned Comfy
  2. I've used the official rocm/pytorch image inside my docker file and also some automations:

FROM rocm/pytorch:latest

WORKDIR /Comfy
RUN pip install -r requirements.txt
RUN pip install hiredis

  1. I've mounted the shared folder in the Image creation process:
    podman build -v /home/user/Comfy:/Comfy -t customcomfy .

  2. I've used the official rocm/pytorch docker container configuration with my shared folder and host network access:

podman create -it
--cap-add=SYS_PTRACE
--security-opt seccomp=unconfined
--device=/dev/kfd
--device=/dev/dri
--group-add video
--ipc=host
--network=host
-v /home/user/Comfy:Comfy
customcomfy

I've used this setup on my Fedora OS, without extra host configurations.

In terms of compatibility for AMD/Intel users, i recommend keeping sensitive dependencies (especially torch) apart from an 'official' comfyui docker image OR include an alternative image for AMD users which uses the:
"FROM rocm/pytorch:latest" statement before installing comfy requirements.txt.

Please also Note that on SELinux systems using a shared folder requires either a "z" or "Z" statement, so in terms of Fedora it would look like:
-v /home/user/Comfy:/Comfy:Z or :z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants