Docker 安装 RAGFlow保姆教程
前提条件
- Ubuntu 服务器(20.04 或 22.04 LTS 推荐)
- 已安装 Docker 和 Docker Compose
- 如果尚未安装,请先运行以下命令:
# 安装 Docker curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # 将当前用户加入 docker 组,避免每次都要 sudo sudo usermod -aG docker $USER newgrp docker # 刷新组权限,或重新登录服务器生效# 安装 Docker Compose 插件 sudo apt-get update sudo apt-get install docker-compose-plugin # 验证安装 docker compose version
- 如果尚未安装,请先运行以下命令:
- 确保服务器端口
80
和8010
未被其他程序占用。RAGFlow 默认使用这些端口。
安装步骤
第 1 步:下载部署文件
首先,创建一个项目目录并进入,然后从 GitHub 拉取 RAGFlow 的 Docker Compose 配置文件。
# 创建并进入一个目录,例如 ragflow
mkdir ragflow && cd ragflow# 从 GitHub 拉取 RAGFlow 的 Docker Compose 配置文件
git clone https://github.com/infiniflow/ragflow.git
第 2 步:修改RAGFlow配置
RAGFlow依赖组件包括Mysql、Redis、MinIO、Nginx等,因为我的服务之前已安装过这些组件,防止端口冲突,影响RAGFlow启动。
- 修改docker-compose.yml中nginx的端口从80修改成8580,443修改成8443
注意:原则不在配置这个 docker-compose.yml直接修改端口号,正确的做法应该是修改环境变量
include:- ./docker-compose-base.yml
# To ensure that the container processes the locally modified `service_conf.yaml.template` instead of the one included in its image, you need to mount the local `service_conf.yaml.template` to the container.
services:ragflow:depends_on:mysql:condition: service_healthyimage: ${RAGFLOW_IMAGE}# Example configuration to set up an MCP server:# command:# - --enable-mcpserver# - --mcp-host=0.0.0.0# - --mcp-port=9382# - --mcp-base-url=http://127.0.0.1:9380# - --mcp-script-path=/ragflow/mcp/server/server.py# - --mcp-mode=self-host# - --mcp-host-api-key=ragflow-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# Optional transport flags for MCP (customize if needed).# Host mode need to combined with --no-transport-streamable-http-enabled flag, namely, host+streamable-http is not supported yet.# The following are enabled by default unless explicitly disabled with --no-<flag>.# - --no-transport-sse-enabled # Disable legacy SSE endpoints (/sse and /messages/)# - --no-transport-streamable-http-enabled # Disable Streamable HTTP transport (/mcp endpoint)# - --no-json-response # Disable JSON response mode in Streamable HTTP transport (instead of SSE over HTTP)container_name: ragflow-serverports:- ${SVR_HTTP_PORT}:9380- 8580:80 #修改1- 8443:443 #修改2- 5678:5678 - 5679:5679- 9382:9382 # entry for MCP (host_port:docker_port). The docker_port must match the value you set for `mcp-port` above.volumes:- ./ragflow-logs:/ragflow/logs- ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf- ./nginx/proxy.conf:/etc/nginx/proxy.conf- ./nginx/nginx.conf:/etc/nginx/nginx.conf- ../history_data_agent:/ragflow/history_data_agent- ./service_conf.yaml.template:/ragflow/conf/service_conf.yaml.template- ./entrypoint.sh:/ragflow/entrypoint.shenv_file: .envenvironment:- TZ=${TIMEZONE}- HF_ENDPOINT=$