目录
Xinference%E9%83%A8%E7%BD%B2-toc" name="tableOfContents" style="margin-left:0px">一、Xinference部署
(一)简介
(二)部署
(三)参数
(四)错误问题
二、下载Reranker模型
(一)huggingface下载
(二)modelcope 下载
Xinference%E9%85%8D%E7%BD%AEText-embedding%E6%A8%A1%E5%9E%8B%C2%A0-toc" name="tableOfContents" style="margin-left:40px">(三)Xinference配置Text-embedding模型
Xinference%E9%85%8D%E7%BD%AE%E6%8E%92%E5%BA%8F%E6%A8%A1%E5%9E%8B-toc" name="tableOfContents" style="margin-left:40px">(四)Xinference配置排序模型
RAGFlow%E9%83%A8%E7%BD%B2-toc" name="tableOfContents" style="margin-left:0px">三、RAGFlow部署
(一)克隆仓库
(二) 使用预构建的Docker镜像并启动服务器
(三)服务器启动并运行后,检查服务器状态
(四)访问
(五)部署RAGFlow遇到的问题
Dify%E9%83%A8%E7%BD%B2-toc" name="tableOfContents" style="margin-left:0px">四、 Dify部署
(一)克隆代码到本地环境
Dify-toc" name="tableOfContents" style="margin-left:40px">(二)启动 Dify
Dify-toc" name="tableOfContents" style="margin-left:40px">(三)更新 Dify
Dify-toc" name="tableOfContents" style="margin-left:40px">(四)访问 Dify
(五)自定义配置
(六)部署dify遇到的问题
问题1:访问dify管理员页面的时候转圈卡住
问题2:管理员账号输入太多次被锁住,需要等24小时
Ollama%E9%83%A8%E7%BD%B2-toc" name="tableOfContents" style="margin-left:0px">五、Ollama部署
六、WebUI
(一)步骤1:拉取Open web镜像
(二)步骤2:运行容器
六、进行组合
Ollama-toc" name="tableOfContents" style="margin-left:40px">(一)Ragflow添加Ollama
Xinference-toc" name="tableOfContents" style="margin-left:40px">(二)Ragflow添加Xinference
Dify%E9%85%8D%E7%BD%AEOllama-toc" name="tableOfContents" style="margin-left:40px">(三)Dify集成Ollama
Dify%E9%9B%86%E6%88%90Xinference%20%E6%8E%92%E5%BA%8F%E6%A8%A1%E5%9E%8B-toc" name="tableOfContents" style="margin-left:40px">(四)Dify集成Xinference 排序模型
Dify%E9%9B%86%E6%88%90RAGFlow%C2%A0-toc" name="tableOfContents" style="margin-left:40px">(五)Dify集成RAGFlow
七、docker常见问题
(一)遇到 Docker 容器名称冲突错误,说明你尝试创建或运行的容器名称已被其他容器占用。以下是分步解决方案:
(二)当需要运行一个已有的 Docker 容器时,通常有两种情况:启动已停止的容器 或 基于现有镜像创建并运行新容器。
一、Xinference部署
(一)简介
Xorbits Inference (Xinference) 是一个开源平台,用于简化各种 AI 模型的运行和集成。借助 Xinference,您可以使用任何开源 LLM、嵌入模型和多模态模型在云端或本地环境中运行推理,并创建强大的 AI 应用。
项目地址:https://github.com/xorbitsai/inference#/
文档地址:https://inference.readthedocs.io/zh-cn/latest/#/
(二)部署
docker run \--name xinference \-d \-p 9998:9997 \-e XINFERENCE_HOME=/data/2-model \-v $(pwd):/data/2-model \--gpus all \xprobe/xinference:latest \xinference-local -H 0.0.0.0
部署成功之后可以直接访问:http://localhost:9998
(三)参数
-
docker run
- 启动一个新的Docker容器 -
--name xinference
- 将容器命名为"xinference" -
-d
- 以分离(后台)模式运行容器 -
-p 99978:9997
- 将容器的9998端口映射到主机的9997端口 -
-e XINFERENCE_HOME=/data/model
- 设置环境变量,指定Xinference的主目录为容器内的/data/model -
-v $(pwd):/data/model
- 将当前工作目录挂载到容器内的/data/model目录,实现数据持久化 -
--gpus all
- 允许容器使用主机上的所有GPU资源 -
xprobe/xinference:latest
- 使用最新版本的xprobe/xinference镜像 -
xinference-local -H 0.0.0.0
- 在容器内运行xinference-local命令,并设置主机地址为0.0.0.0(允许从任何IP地址访问)
(四)错误问题
在运行的时候报错提示:Unable to find image 'xprobe/xinference:latest' locally
Unable to find image 'xprobe/xinference:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
需要更换docker的下载源(一定要找到合适的源):
1.打开配置文件
vim /etc/docker/daemon.json
2.加入如下内容
{
"registry-mirrors": ["https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc"]
}
3.执行以下命令,使生效
systemctl daemon-reload
systemctl restart docker
参考:解决docker: Error response from daemon: Get “https://registry-1.docker.io/v2/“: net/http: request canc_docker_君子如玉zzZ-腾讯云开发者社区
二、下载Reranker模型
通过huggingface或者modelcope下载
(一)huggingface下载
地址:https://huggingface.co/ 或者 国内可用镜像地址:HF-Mirror
huggingface-cli download --resume-download BAAI/bge-reranker-v2-m3
(二)modelcope 下载
地址:魔搭社区
modelscope download --model BAAI/bge-reranker-v2-m3
Xinference%E9%85%8D%E7%BD%AEText-embedding%E6%A8%A1%E5%9E%8B%C2%A0" name="%EF%BC%88%E4%B8%89%EF%BC%89Xinference%E9%85%8D%E7%BD%AEText-embedding%E6%A8%A1%E5%9E%8B%C2%A0">(三)Xinference配置Text-embedding模型
Xinference%E9%85%8D%E7%BD%AE%E6%8E%92%E5%BA%8F%E6%A8%A1%E5%9E%8B" name="%EF%BC%88%E4%B8%89%EF%BC%89Xinference%E9%85%8D%E7%BD%AE%E6%8E%92%E5%BA%8F%E6%A8%A1%E5%9E%8B">(四)Xinference配置排序模型
添加成功,运行模型:
RAGFlow%E9%83%A8%E7%BD%B2" name="%E4%B8%89%E3%80%81RAGFlow%E9%83%A8%E7%BD%B2">三、RAGFlow部署
RAGFlow 是一款基于深度文档理解构建的开源 RAG(Retrieval-Augmented Generation)引擎。RAGFlow 可以为各种规模的企业及个人提供一套精简的 RAG 工作流程,结合大语言模型(LLM)针对用户各类不同的复杂格式数据提供可靠的问答以及有理有据的引用。
项目地址:https://github.com/infiniflow/ragflow
文档地址:https://ragflow.io/docs/dev/
(一)克隆仓库
使用docker安装
git clone https://github.com/infiniflow/ragflow.git
cd ragflow/docker
git checkout -f v0.17.2
完成后如下图所示:
(二) 使用预构建的Docker镜像并启动服务器
注意: 上面的命令会下载v0.17.2-slim
版本的RAGFlow Docker镜像。有关不同RAGFlow版本的说明,请参考下表。如果要下载不同于v0.17.2-slim
的RAGFlow版本,请在使用docker compose
启动服务器之前,在docker/.env中相应地更新RAGFLOW_IMAGE
变量。例如:设置RAGFLOW_IMAGE=infiniflow/ragflow:v0.17.2
以获取完整版本v0.17.2
。
在当前目录下
vim ragflow/docker/.env
官方给出默认使用CPU进行嵌入和DeepDoc任务,但我们一般使用的是GPU
# Use CPU for embedding and DeepDoc tasks:
# docker compose -f docker-compose.yml up -d# To use GPU to accelerate embedding and DeepDoc tasks:
docker compose -f docker-compose-gpu.yml up -d
RAGFlow image tag | Image size (GB) | Has embedding models and Python packages? | Stable? |
---|---|---|---|
v0.17.2 | ≈9 | ✔️ | Stable release |
v0.17.2-slim | ≈2 | ❌ | Stable release |
nightly | ≈9 | ✔️ | Unstable nightly build |
nightly-slim | ≈2 | ❌ | Unstable nightly build |
执行完如下图:
以上提示ragflow-server 的端口号被占用了,修改下端口号:
来自守护进程的错误响应:驱动程序编程失败外部连接端点ragflow-server (46624c43ac270416224d934ebe1f5894d0b275cd330bde66693f73b68bba9ae2):绑定0.0.0.0:443失败:端口已经分配
Error response from daemon: driver failed programming external connectivity on endpoint ragflow-server (46624c43ac270416224d934ebe1f5894d0b275cd330bde66693f73b68bba9ae2): Bind for 0.0.0.0:443 failed: port is already allocated
Error response from daemon: driver failed programming external connectivity on endpoint ragflow-server (69718cf5c226f76a3acc7dd5228731d276b19221e0bfb9ecd9f46230424581d1): Bind for 0.0.0.0:80 failed: port is already allocated
改完后,再重启容器
docker-compose up -d
(三)服务器启动并运行后,检查服务器状态
docker logs -f ragflow-server
(四)访问
在浏览器中输入服务器
的IP地址:81,登录RAGFlow
(五)部署RAGFlow遇到的问题
执行命令:docker compose -f docker-compose-gpu.yml up -d,提示unknown shorthand flag: 'f' in -f
查看版本号:docker -v
1. 确认 Docker 版本是否支持 Compose V2
Compose V2 需要 Docker Engine 20.10 或更高版本。运行以下命令检查 Docker 版本:
docker --version
-
如果版本低于
20.10
,需先升级 Docker:-
Linux:使用包管理器升级(如
apt
、yum
)。 -
macOS/Windows:下载最新版 Docker Desktop。
-
2. 安装 Docker Compose V2 插件
如果 Docker 版本符合要求但缺少插件,需手动安装:
方法 1:通过 Docker 官方脚本安装
# 下载并安装 Compose V2 插件
mkdir -p ~/.docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
方法 2:使用包管理器安装(Linux)
-
Debian/Ubuntu:
sudo apt update sudo apt install docker-compose-plugin
-
CentOS/RHEL:
sudo yum install docker-compose-plugin
验证安装
docker compose version
# 输出应包含 `Docker Compose version v2.x.x`
3. 退而使用 Docker Compose V1
如果无法安装 V2 插件,可直接使用旧版 docker-compose
(V1):
安装 Docker Compose V1
# 下载独立脚本
sudo curl -L "https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
验证安装
docker-compose --version
# 输出应类似 `docker-compose version 1.29.2`
4. 根据版本选择命令
-
Compose V2 插件:使用
docker compose ...
docker compose -f docker-compose-gpu.yml up -d
-
Compose V1 独立版:使用
docker-compose ...
docker-compose -f docker-compose-gpu.yml up -d
5. 其他可能的问题
-
权限问题:确保插件或脚本有执行权限。
-
路径问题:检查
~/.docker/cli-plugins
或/usr/local/bin
是否在系统PATH
中。 -
重启 Docker 服务:安装后重启 Docker 守护进程:
sudo systemctl restart docker
Dify%E9%83%A8%E7%BD%B2" name="%E5%9B%9B%E3%80%81%C2%A0Dify%E9%83%A8%E7%BD%B2">四、 Dify部署
Dify 是一款开源的大语言模型(LLM) 应用开发平台。它融合了后端即服务(Backend as Service)和 LLMOps 的理念,使开发者可以快速搭建生产级的生成式 AI 应用。即使你是非技术人员,也能参与到 AI 应用的定义和数据运营过程中。
项目地址:https://github.com/langgenius/dify 文档地址:https://docs.dify.ai/zh-hans#/
下载对应版本:
https://github.com/langgenius/dify/tags
(一)克隆代码到本地环境
git clone https://github.com/langgenius/dify.git --branch 0.15.4(最新版本)
Dify" name="%EF%BC%88%E4%BA%8C%EF%BC%89%E5%90%AF%E5%8A%A8%20Dify">(二)启动 Dify
-
进入 Dify 源代码的 Docker 目录
cd dify/docker
-
复制环境配置文件
cp .env.example .env
-
启动 Docker 容器
根据你系统上的 Docker Compose 版本,选择合适的命令来启动容器。你可以通过
$ docker compose version
命令检查版本,详细说明请参考 Docker 官方文档:-
如果版本是 Docker Compose V2,使用以下命令:
docker compose up -d
-
如果版本是 Docker Compose V1,使用以下命令:
docker-compose up -d
-
运行命令后,你应该会看到类似以下的输出,显示所有容器的状态和端口映射:
最后检查是否所有容器都正常运行:
docker compose ps
Dify" name="%EF%BC%88%E4%B8%89%EF%BC%89%E6%9B%B4%E6%96%B0%20Dify">(三)更新 Dify
进入 dify 源代码的 docker 目录,按顺序执行以下命令:
cd dify/docker
docker compose down
git pull origin main
docker compose pull
docker compose up -d
同步环境变量配置 (重要!)
-
如果
.env.example
文件有更新,请务必同步修改你本地的.env
文件。 -
检查
.env
文件中的所有配置项,确保它们与你的实际运行环境相匹配。你可能需要将.env.example
中的新变量添加到.env
文件中,并更新已更改的任何值。
Dify" name="%EF%BC%88%E5%9B%9B%EF%BC%89%E8%AE%BF%E9%97%AE%20Dify">(四)访问 Dify
你可以先前往管理员初始化页面设置设置管理员账户:
# 本地环境
http://localhost/install# 服务器环境
http://your_server_ip/install
Dify 主页面:
# 本地环境
http://localhost# 服务器环境
http://your_server_ip
(五)自定义配置
编辑 .env
文件中的环境变量值。然后重新启动 Dify:
docker compose down
docker compose up -d
完整的环境变量集合可以在 docker/.env.example
中找到。
(六)部署dify遇到的问题
问题1:访问dify管理员页面的时候转圈卡住
F12查看错误码为502:
解决方法:
Dify转圈圈报502错误,是nginx启动太早了,在docker重启nginx服务,或者命令行:docker compose restart nginx
docker compose restart nginx
问题2:管理员账号输入太多次被锁住,需要等24小时
解决方法:连上 Redis
,删除这个 超时的Key
docker exec -it docker-redis-1 sh
然后输入
redis-cli # 进入命令
keys * # 查看keys
ttl login_error_rate_limit:admin@126.com # 看当前用户还有多少限时
del login_error_rate_limit:admin@126.com # 删除限时
完成后,就可以继续登录了!
Ollama%E9%83%A8%E7%BD%B2" name="%E4%BA%94%E3%80%81Ollama%E9%83%A8%E7%BD%B2">五、Ollama部署
可参考:在Linux系统安装Ollama两种方法:自动安装和手动安装,并配置自启动服务 -CSDN博客
六、WebUI
项目地址:GitHub - open-webui/open-webui: User-friendly AI Interface (Supports Ollama, OpenAI API, ...) 文档地址:🏡 Home | Open WebUI
(一)步骤1:拉取Open web镜像
首先从GitHub Container Registry中提取最新的Open web Docker镜像。
docker pull ghcr.io/open-webui/open-webui:main
(二)步骤2:运行容器
使用默认设置运行容器。该命令包括一个卷映射,以确保数据的持久存储。
docker run -d \
-p 3000:8080 \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/data/6-docker \
--name open-webui \
--restart always \
ghcr.io/open-webui/open-webui:main
1. 参数说明:
Volume Mapping(-v open-webui:/app/backend/data):确保数据的持久存储。这可以防止容器重启之间的数据丢失。
Port Mapping(-p 3000:8080):在本地机器的端口3000上公开web。
2. 使用GPU支持
对于Nvidia GPU支持,在docker run命令中添加——GPU all:
docker run -d \
-p 3000:8080 \
--gpus all \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/data/6-docker \
--name open-webui \
--restart always \
ghcr.io/open-webui/open-webui:cuda
3. 单用户模式(禁止登录)
要绕过单用户设置的登录页面,将WEBUI_AUTH环境变量设置为False:
docker run -d \
-p 3000:8080 \
-e WEBUI_AUTH=False \
-v open-webui:/app/backend/data \
--name open-webui \
ghcr.io/open-webui/open-webui:main
提醒:修改完成后,不能在单用户模式和多用户模式之间进行切换。
4. 高级配置:连接到另一台服务器上的Ollama
要将Open web连接到位于另一台主机上的Ollama服务器,请添加OLLAMA_BASE_URL环境变量:
docker run -d \
-p 3000:8080 \
-e OLLAMA_BASE_URL=https://example.com \
-v open-webui:/app/backend/data \
--name open-webui \
--restart always \
ghcr.io/open-webui/open-webui:main
5. 访问web界面
容器运行后,进入Open WebUI:
http://localhost:3000
(三)更新
要将本地Docker安装更新到最新版本,您可以使用Watchtower或手动更新容器。
选项1:使用瞭望塔
使用瞭望塔,您可以自动更新过程:
docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once open-webui
(如果不同,请将open-web替换为您的容器名称。)
选项2:手动更新
1. 停止并移除当前容器:
docker rm -f open-webui
2. 获取最新版本:
docker pull ghcr.io/open-webui/open-webui:main
3.再次启动容器:
docker run -d -p 3000:8080 -v open-webui:/app/backend/data --name open-webui ghcr.io/open-webui/open-webui:main
这两种方法都会让你的Docker实例更新并运行最新的版本。
下一个步骤 安装完成后,访问:
通过http://localhost:3000访问Open web。
或http://localhost:8080/,当使用Python部署时。
六、进行组合
Ollama" name="%EF%BC%88%E4%B8%80%EF%BC%89Ragflow%E6%B7%BB%E5%8A%A0Ollama">(一)Ragflow添加Ollama
Xinference" name="%EF%BC%88%E4%BA%8C%EF%BC%89Ragflow%E6%B7%BB%E5%8A%A0Xinference">(二)Ragflow添加Xinference
Dify%E9%85%8D%E7%BD%AEOllama" name="%EF%BC%88%E4%B8%89%EF%BC%89Dify%E9%85%8D%E7%BD%AEOllama">(三)Dify集成Ollama
1. 打开设置
2. 添加Ollama模型
Dify%E9%9B%86%E6%88%90Xinference%20%E6%8E%92%E5%BA%8F%E6%A8%A1%E5%9E%8B" name="%EF%BC%88%E5%9B%9B%EF%BC%89Dify%E9%9B%86%E6%88%90Xinference%20%E6%8E%92%E5%BA%8F%E6%A8%A1%E5%9E%8B">(四)Dify集成Xinference 排序模型
1. 选择
2.
Dify%E9%9B%86%E6%88%90RAGFlow%C2%A0" name="%EF%BC%88%E4%BA%94%EF%BC%89Dify%E9%9B%86%E6%88%90RAGFlow%C2%A0">(五)Dify集成RAGFlow
1. 在RAGFlow中创建新密钥
2. 获取RAGFlow的知识库ID
3. Dify添加外部知识库
七、docker常见问题
(一)遇到 Docker 容器名称冲突错误,说明你尝试创建或运行的容器名称已被其他容器占用。以下是分步解决方案:
1. 查看已存在的同名容器
首先确认冲突容器的状态:
# 列出所有容器(包括已停止的),过滤名称 "xinference"
docker ps -a | grep "xinference"
输出示例:
bcac7f08fb09 xinference-image "/entrypoint.sh" 2 hours ago Exited (0) 1 hour ago xinference
2. 根据需求选择操作
场景 1:不需要保留旧容器
直接删除占用名称的旧容器:
# 强制删除容器(无论是否在运行)
docker rm -f xinference# 或分步操作(先停止后删除)
docker stop xinference
docker rm xinference
场景 2:需要保留旧容器但继续使用名称
修改新容器的名称(例如添加后缀):
# 在 docker run 时指定新名称
docker run --name xinference-new -d your-image# 或在 docker-compose.yml 中修改服务名
services:xinference-new: # 修改此处名称image: your-image
3. 重新运行容器
清除冲突后,重新执行原始命令:
# 直接运行(名称已释放)
docker run --name xinference -d your-image# 或使用 docker-compose
docker-compose up -d
4. 防止未来冲突
(1) 自动清理旧容器(适合临时容器)
运行容器时添加 --rm
参数,容器停止后自动删除:
docker run --rm --name xinference -d your-image
(2) 定期清理无用容器
# 删除所有已停止的容器
docker container prune
(二)当需要运行一个已有的 Docker 容器时,通常有两种情况:启动已停止的容器 或 基于现有镜像创建并运行新容器。
一、启动已停止的容器
如果容器已存在但处于停止状态(Exited),可以直接启动它:
1. 查看所有容器(包括已停止的)
docker ps -a
输出示例:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1b2c3d4e5f6 nginx:latest "nginx -g ..." 2 hours ago Exited (0) 10 minutes ago my-nginx
2. 启动指定容器
docker start <容器ID或名称>
# 示例
docker start a1b2c3d4e5f6
docker start my-nginx
3. 检查容器状态
docker ps | grep my-nginx
4. 查看容器日志(调试启动问题)
docker logs my-nginx
二、基于现有镜像运行新容器
如果希望基于已有镜像创建一个新容器(而非复用旧容器):
1. 查找可用镜像
docker images
输出示例:
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 2 weeks ago 141MB
2. 运行新容器
docker run [选项] <镜像名称或ID>
常用选项:
选项 | 说明 |
---|---|
| 后台运行(守护模式) |
| 指定容器名称(避免随机命名冲突) |
| 端口映射(如 |
| 数据卷挂载 |
| 交互式终端(常用于调试) |
示例:
# 后台运行并命名容器
docker run -d --name my-nginx-new -p 80:80 nginx:latest# 带交互式终端(退出后容器停止)
docker run -it --name my-alpine alpine:latest sh
三、处理常见问题
1. 端口冲突
若提示 port is already allocated
,需修改端口映射或释放占用端口:
# 修改主机端口(如 8080:80)
docker run -d --name my-nginx-new -p 8080:80 nginx:latest
2. 容器名称冲突
若提示 container name already in use
,删除旧容器或指定新名称:
# 强制删除旧容器
docker rm -f my-nginx-old# 或运行新容器时换名
docker run -d --name my-nginx-v2 nginx:latest
3. 容器启动后自动退出
检查容器日志,通常是因为主进程结束:
docker logs my-nginx
-
解决方案:确保容器内有持久化进程(如使用
nginx -g "daemon off;"
)。
四、使用 Docker Compose 管理容器
如果容器是通过 docker-compose.yml
定义的:
1. 启动所有服务
docker-compose up -d
2. 启动单个服务
docker-compose up -d <服务名>
3. 重建容器(修改配置后)
docker-compose up -d --build <服务名>
五、总结
场景 | 命令 |
---|---|
启动已停止的容器 | docker start <容器ID或名称> |
创建并运行新容器 | docker run -d --name <名称> -p 端口:端口 <镜像> |
解决端口/名称冲突 | 修改端口映射或容器名称,或删除旧容器 |
调试容器启动失败 | docker logs <容器名> |
参考:AI老板心中的迈巴赫:DeepSeek+Ollama+Xinference+RAGFlow+Dify部署教程,RAG落地5件套!