docker-compose-gpu.yml
Overview
This docker-compose-gpu.yml file is a Docker Compose configuration designed to deploy the RAGFlow server with GPU support. It extends a base Docker Compose file (docker-compose-base.yml) and configures the RAGFlow service to run within a containerized environment that leverages NVIDIA GPUs for hardware acceleration. It also integrates necessary services, networking, volumes, and environment configurations required for RAGFlow to operate properly in a GPU-enabled Docker setup.
Important Note:
The RAGFlow team does not actively maintain this file, and users are advised to use it at their own risk. Contributions via pull requests are welcome to improve it.
Detailed Explanation
File Structure and Components
The file is structured to define one main service (ragflow) that depends on a MySQL database service and includes GPU resource reservations. It also incorporates external configuration files, environment variables, and Docker networking.
include:
- ./docker-compose-base.yml
Purpose:
This line imports and merges the base Docker Compose configuration (docker-compose-base.yml) into this GPU-specific setup. This allows reuse of common service definitions, network settings, and volumes.
Service: ragflow
This is the primary service defined in this file. It represents the RAGFlow server container configured to utilize NVIDIA GPUs.
Property | Description |
|---|---|
| Specifies service dependencies. Here, |
| Docker image to use for the |
| Sets the container name to |
| Maps host ports to container ports: |
| Mounts local directories and files into the container: |
| Loads environment variables from a |
| Additional environment variables: |
| Connects the container to the |
| Configured to restart the container on failure. |
| Adds an entry |
| Reserves GPU devices for this container using the NVIDIA Docker runtime, requesting access to all GPUs ( |
Key Implementation Details
GPU Support:
Thedeploy.resources.reservations.devicessection is crucial to enable GPU access in Docker containers. It uses the NVIDIA container runtime (driver: nvidia) and requests all available GPUs. This allows the RAGFlow server to leverage GPU acceleration for compute-intensive tasks such as machine learning inference.Dependency on MySQL:
The service waits for themysqlservice to be healthy before starting. This ensures the database backend is ready, avoiding race conditions during startup.Nginx Configuration Volumes:
The Nginx configuration files are mounted into the container, indicating that Nginx is used as a reverse proxy inside theragflowcontainer or in the containerized environment to handle HTTP/HTTPS traffic routing.Prometheus Integration Hint:
Theextra_hostsentry withhost.docker.internalis recommended for monitoring setups, especially when using Prometheus to scrape metrics from containers on Docker Desktop environments.
Usage Example
Assuming you have the necessary environment variables set in your .env file and the base compose file present, you can start the GPU-enabled RAGFlow stack with:
docker-compose -f docker-compose-gpu.yml up -d
This command will:
Pull or use the specified RAGFlow image.
Start the MySQL service (from the included base compose file).
Start the
ragflowservice with GPU support.Map ports and mount volumes as configured.
Ensure the container restarts on failure.
Interaction with Other Parts of the System
Base Compose File (
docker-compose-base.yml):
This file is extended, so the base file likely defines common services such as the MySQL database, networks, and other shared configurations.MySQL Service:
Theragflowservice depends on the MySQL database, which provides persistent storage and data management for the application.Nginx Configurations:
Mounted Nginx config files suggest that this service includes or interacts with a reverse proxy setup, which could be responsible for routing requests, SSL termination, and load balancing.Environment Variables:
The.envfile and explicit environment variables configure runtime parameters such as the image tag, HTTP ports, time zone, and external service endpoints.GPU Resources:
This file configures the Docker environment to allow access to the host's NVIDIA GPUs, enabling accelerated computing.
Mermaid Diagram: Service Dependency and Configuration Flow
flowchart TD
A[Start Docker Compose GPU Setup] --> B[Include docker-compose-base.yml]
B --> C[Start mysql service]
C -->|Wait until healthy| D[Start ragflow service]
D --> E{Configure ragflow service}
E --> F[Set image: ${RAGFLOW_IMAGE}]
E --> G[Expose ports: ${SVR_HTTP_PORT}:9380, 80:80, 443:443]
E --> H[Mount volumes for logs and nginx configs]
E --> I[Load env vars from .env and environment block]
E --> J[Connect to ragflow network]
E --> K[Set restart policy: on-failure]
E --> L[Add extra_hosts: host.docker.internal]
E --> M[Reserve GPU devices with NVIDIA driver]
Summary
The
docker-compose-gpu.ymlfile configures a GPU-enabled deployment of the RAGFlow server.It extends a base Docker Compose file to reuse common services and networks.
The
ragflowservice depends on a healthy MySQL service.GPU resources are explicitly reserved via NVIDIA Docker runtime integration.
Nginx configuration files and environment variables customize the container behavior.
The setup is intended for advanced deployments where GPU acceleration is required.
Users should be cautious since this file is not actively maintained by the RAGFlow team.
This documentation should help developers and DevOps engineers understand, maintain, and extend the GPU-enabled RAGFlow Docker deployment.