构建 ComfyUI Docker image 记录

从干净的ubuntu image 一步一步构建自己需要的 comfyui image

手动构建过程

系统版本

基于 ubuntu:latest image, 版本:

Linux version 6.8.0-49-generic (buildd@lcy02-amd64-028) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0, GNU ld (GNU Binutils for Ubuntu) 2.42) #49-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 4 02:06:24 UTC 2024

启动 docker

docker run -it --gpus all -e HTTP_PROXY=http://192.168.199.35:9090 -e HTTPS_PROXY=http://192.168.199.35:9090 --user root ubuntu:latest /bin/bash

安装GCC

$ apt install gcc -y
$ apt install build-essential -y

安装 git

apt install git

安装 PIP

apt install python3-pip

安装 FFMPEG 相关

(插件需要)

apt-get update && apt-get install libgl1
apt-get install -y libglib2.0-0 libsm6 libxrender1 libxext6

Clone ComfyUI

git clone https://github.com/comfyanonymous/ComfyUI.git ComfyUI

安装依赖

1、 允许pip全局安装

mkdir -p ~/.config/pip
echo "[install]" >> ~/.config/pip/pip.conf
echo "break-system-packages = true" >> ~/.config/pip/pip.conf

2、安装 依赖

$ cd ComfyUI
$ pip install --no-cache-dir -r requirements.txt

3、插件安装(根据自己需要)

git clone https://github.com/ltdrdata/ComfyUI-Manager.git & \
git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git & \
git clone https://github.com/jags111/efficiency-nodes-comfyui & \
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git & \
git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git & \
git clone https://github.com/cubiq/ComfyUI_InstantID.git & \
git clone https://github.com/sipherxyz/comfyui-art-venture.git & \
git clone https://github.com/Gourieff/comfyui-reactor-node.git & \
git clone https://github.com/rgthree/rgthree-comfy.git & \
git clone https://github.com/cubiq/ComfyUI_essentials.git & \
git clone https://github.com/kijai/ComfyUI-SUPIR.git & \
git clone https://github.com/storyicon/comfyui_segment_anything.git & \

cd comfyui-reactor-node && pip install --no-cache-dir -r requirements.txt
cd ComfyUI-Manager && pip install --no-cache-dir -r requirements.txt
cd ComfyUI-SUPIR && pip install --no-cache-dir -r requirements.txt
cd ComfyUI_InstantID && pip install --no-cache-dir -r requirements.txt
cd ComfyUI_essentials && pip install --no-cache-dir -r requirements.txt
cd comfyui-art-venture && pip install --no-cache-dir -r requirements.txt
cd comfyui-reactor-node && pip install --no-cache-dir -r requirements.txt
cd comfyui_controlnet_aux && pip install --no-cache-dir -r requirements.txt
cd comfyui_segment_anything && pip install --no-cache-dir -r requirements.txt
cd efficiency-nodes-comfyui && pip install --no-cache-dir -r requirements.txt
cd was-node-suite-comfyui && pip install --no-cache-dir -r requirements.txt

制作成 Dockerfile

FROM ubuntu:latest
# 安装相关库
RUN apt update
RUN apt install gcc -y
RUN apt install build-essential -y
RUN apt install git -y
# py 环境
RUN apt install python3-pip
RUN mkdir -p ~/.config/pip
RUN echo "[install]" >> ~/.config/pip/pip.conf
RUN echo "break-system-packages = true" >> ~/.config/pip/pip.conf

# ComfyUI 安装
RUN git clone https://github.com/comfyanonymous/ComfyUI.git ComfyUI
WORKDIR /ComfyUI 

# 安装 Python 依赖
RUN pip3 install --no-cache-dir -r requirements.txt

# 安装插件 (根据自己需要添加或减少。)
# 插件的模型需自己下载到宿主机
RUN cd custom_nodes && \
git clone https://github.com/ltdrdata/ComfyUI-Manager.git && \
git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git && \
git clone https://github.com/jags111/efficiency-nodes-comfyui && \
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git && \
git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git && \
git clone https://github.com/cubiq/ComfyUI_InstantID.git && \
git clone https://github.com/sipherxyz/comfyui-art-venture.git && \
git clone https://github.com/Gourieff/comfyui-reactor-node.git && \
git clone https://github.com/rgthree/rgthree-comfy.git && \
git clone https://github.com/cubiq/ComfyUI_essentials.git && \
git clone https://github.com/kijai/ComfyUI-SUPIR.git && \
git clone https://github.com/storyicon/comfyui_segment_anything.git

WORKDIR /ComfyUI/custom_nodes/
RUN cd comfyui-reactor-node && pip install --no-cache-dir -r requirements.txt
RUN cd ComfyUI-Manager && pip install --no-cache-dir -r requirements.txt
RUN cd ComfyUI-SUPIR && pip install --no-cache-dir -r requirements.txt
RUN cd ComfyUI_InstantID && pip install --no-cache-dir -r requirements.txt
RUN cd ComfyUI_essentials && pip install --no-cache-dir -r requirements.txt
RUN cd comfyui-art-venture && pip install --no-cache-dir -r requirements.txt
RUN cd comfyui-reactor-node && pip install --no-cache-dir -r requirements.txt
RUN cd comfyui_controlnet_aux && pip install --no-cache-dir -r requirements.txt
RUN cd comfyui_segment_anything && pip install --no-cache-dir -r requirements.txt
RUN cd efficiency-nodes-comfyui && pip install --no-cache-dir -r requirements.txt
RUN cd was-node-suite-comfyui && pip install --no-cache-dir -r requirements.txt 

# 插件需要
RUN apt-get update && apt-get install -y libgl1
RUN apt-get install -y libglib2.0-0 libsm6 libxrender1 libxext6

CMD ["python3", "/ComfyUI/main.py", "--listen", "0.0.0.0"]

docker build -t comfyui_wj:latest .

启动命令记录

docker run -it --gpus all \
-e HTTP_PROXY=http://192.168.199.35:9090 \
-e HTTPS_PROXY=http://192.168.199.35:9090 \
-v /home/wangjian/comfyUIOutput:/ComfyUI/output \
-v /home/wangjian/AIProject/comfyui/ComfyUI/models:/ComfyUI/models \
-v /home/wangjian/AIProject/Sd/stable-diffusion-webui/models/Stable-diffusion:/ComfyUI/models/checkpoints \
-p 9000:8188 \
--user root  comfyui:0.4 python3 /ComfyUI/main.py --listen 0.0.0.0



docker run -it --gpus all \
-e HTTP_PROXY=http://192.168.199.35:9090 \
-e HTTPS_PROXY=http://192.168.199.35:9090 \
-v /home/wangjian/comfyUIOutput:/ComfyUI/output \
-v /home/wangjian/AIProject/comfyui/ComfyUI/models:/ComfyUI/models \
-v /home/wangjian/AIProject/Sd/stable-diffusion-webui/models/Stable-diffusion:/ComfyUI/models/checkpoints/ \
-p 9000:8188 \
--user root comfyui:0.4  /bin/bash


## dockerfile 构建的,启动测试
docker run -it --gpus all \
-v /home/wangjian/comfyUIOutput:/ComfyUI/output \
-v /home/wangjian/AIProject/comfyui/ComfyUI/models:/ComfyUI/models \
-v /home/wangjian/AIProject/Sd/stable-diffusion-webui/models/Stable-diffusion:/ComfyUI/models/checkpoints \
-p 9000:8188 comfyui_wj

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容