-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Add local Docker support #9305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add local Docker support #9305
Conversation
|
Thanks for making this PR. I'm going to give this a try on Win11 with a RTX4090. |
|
Tried your latest changes - entrypoint.sh is not mounted in the container. So following your README steps 1:1 results in an error. |
@Ambrosiussen That's strange; the image shouldn't have even completed its build if ENTRYPOINT []
CMD pwd; ls -laedit: |
|
Okay so I tried a couple things:
|
|
I believe I figured it out. The error message Theoretically, adding the I’ll push a fix soon. After that, you can run: |
|
What’s catching my attention now is the message: |
1250f8d to
3f8cb79
Compare
|
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! As my first contribution to this PR, I make some little suggestions as follows to make the code better.
Docker officially says compose file should be named as
As you possibly know, the following commands can be shortened as If the user does not modify the code at all and there's no need to build the image on every start, Thank you :) |
|
Just to provide my update - latest version of the PR works well! 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. |
|
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.)
I've never seen a
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
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 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? |
20be04f to
d343a7f
Compare
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. |
|
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: This would probably be cleaner to add all of the files as root, and then chown them all to comfyui. And... Also, on FIPS enabled system, this line will cause an issue in the requirements.txt file. The newest versions have an issue with fips. If you set this to 14.2.0 or 14.1.0 I believe it should work. |
|
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.
Could you please pull the latest changes and try again? If the error persists, could you share the full error message?
This shouldn’t happen given the
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. Same thing here. Basically using AV < 15.0.0 should work fine. Ill try and pull and rebuild soon! |
|
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. |
|
@bbergeron0 I shall create an issue on the repo to call YanWenKun here if you don't mind. |
|
@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? |
|
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:
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.) |
|
@YanWenKun Thank you very much for coming! I'm very happy to see you sharing helpful advises here! |
|
Hi @YanWenKun, thanks for the review, I appreciate it! I have a few questions I'd like to ask:
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?
How does ComfyUI-Docker address dependency management, especially regarding CUDA dependencies? So far, my impression has been that installing any |
Yes, it works fine for all ComfyUI Example Workflows, since all models are properly saved under 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 Of course, there’s an alternative: you can redirect these folders by setting environment variables, e.g.: (Note: there’s no equivalent env var for 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. |
The PyTorch release on PyPI follows the stable branch (currently However, when Blackwell (RTX 50 series) was released, the stable branch of PyTorch 2.7 was 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. |
|
as an AMD user, i have used a custom docker setup, which worked very well:
FROM rocm/pytorch:latest WORKDIR /Comfy
podman create -it 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: 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: |
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
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:
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
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:
Tested
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:
Projects
Other projects that combine ComfyUI and Docker: