How to Deploy FastGPT Locally with Docker Compose: A Step‑by‑Step Guide

This guide walks you through installing Docker, configuring Docker‑Compose, setting up FastGPT’s config files, launching the containers, and creating a private knowledge base to enable AI‑driven question answering on your own server.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
How to Deploy FastGPT Locally with Docker Compose: A Step‑by‑Step Guide

FastGPT Overview

FastGPT is an LLM‑based knowledge‑base Q&A system that supports out‑of‑the‑box data processing, model invocation and visual workflow orchestration for complex query scenarios.

Private Deployment with Docker Compose

1. Install Docker and Docker‑Compose

# Install Docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
systemctl enable --now docker
# Install docker‑compose
curl -L https://github.com/docker/compose/releases/download/2.20.3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Verify installation
docker -v
docker-compose -v
If Docker is already installed, you can skip this step.

2. Prepare Working Directory

mkdir tinywan-fastgpt
cd tinywan-fastgpt

3. docker‑compose.yml

version: '3.3'
services:
  pg:
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0
    container_name: pg
    restart: always
    ports:
      - 5432:5432
    networks:
      - fastgpt
    environment:
      - POSTGRES_USER=username
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=postgres
    volumes:
      - ./pg/data:/var/lib/postgresql/data
  mongo:
    image: mongo:5.0.18
    container_name: mongo
    restart: always
    ports:
      - 27017:27017
    networks:
      - fastgpt
    environment:
      - MONGO_INITDB_ROOT_USERNAME=username
      - MONGO_INITDB_ROOT_PASSWORD=password
    volumes:
      - ./mongo/data:/data/db
  fastgpt:
    container_name: fastgpt
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest
    ports:
      - 3000:3000
    networks:
      - fastgpt
    depends_on:
      - mongo
      - pg
    restart: always
    environment:
      - DEFAULT_ROOT_PSW=123465
      - OPENAI_BASE_URL=https://api.openai.com/v1
      - CHAT_API_KEY=YOUR_OPENAI_KEY   # replace with your key
      - DB_MAX_LINK=5
      - TOKEN_KEY=any
      - ROOT_KEY=root_key
      - FILE_TOKEN_KEY=filetoken
      - MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
      - PG_URL=postgresql://username:password@pg:5432/postgres
    volumes:
      - ./config.json:/app/data/config.json
networks:
  fastgpt:
Replace CHAT_API_KEY with your OpenAI key and adjust usernames/passwords as needed.

4. config.json

{
  "SystemParams": {
    "pluginBaseUrl": "",
    "vectorMaxProcess": 15,
    "qaMaxProcess": 15,
    "pgHNSWEfSearch": 100
  },
  "ChatModels": [
    {
      "model": "gpt-3.5-turbo-1106",
      "name": "GPT35-1106",
      "price": 0,
      "maxContext": 16000,
      "maxResponse": 4000,
      "quoteMaxToken": 2000,
      "maxTemperature": 1.2,
      "censor": false,
      "vision": false,
      "defaultSystemChatPrompt": ""
    },
    {
      "model": "gpt-3.5-turbo-16k",
      "name": "GPT35-16k",
      "maxContext": 16000,
      "maxResponse": 16000,
      "price": 0,
      "quoteMaxToken": 8000,
      "maxTemperature": 1.2,
      "censor": false,
      "vision": false,
      "defaultSystemChatPrompt": ""
    },
    {
      "model": "gpt-4",
      "name": "GPT4-8k",
      "maxContext": 8000,
      "maxResponse": 8000,
      "price": 0,
      "quoteMaxToken": 4000,
      "maxTemperature": 1.2,
      "censor": false,
      "vision": false,
      "defaultSystemChatPrompt": ""
    },
    {
      "model": "gpt-4-vision-preview",
      "name": "GPT4-Vision",
      "maxContext": 128000,
      "maxResponse": 4000,
      "price": 0,
      "quoteMaxToken": 100000,
      "maxTemperature": 1.2,
      "censor": false,
      "vision": true,
      "defaultSystemChatPrompt": ""
    }
  ],
  "QAModels": [
    {
      "model": "gpt-3.5-turbo-16k",
      "name": "GPT35-16k",
      "maxContext": 16000,
      "maxResponse": 16000,
      "price": 0
    }
  ],
  "CQModels": [
    {
      "model": "gpt-3.5-turbo-1106",
      "name": "GPT35-1106",
      "maxContext": 16000,
      "maxResponse": 4000,
      "price": 0,
      "functionCall": true,
      "functionPrompt": ""
    },
    {
      "model": "gpt-4",
      "name": "GPT4-8k",
      "maxContext": 8000,
      "maxResponse": 8000,
      "price": 0,
      "functionCall": true,
      "functionPrompt": ""
    }
  ],
  "ExtractModels": [
    {
      "model": "gpt-3.5-turbo-1106",
      "name": "GPT35-1106",
      "maxContext": 16000,
      "maxResponse": 4000,
      "price": 0,
      "functionCall": true,
      "functionPrompt": ""
    }
  ],
  "QGModels": [
    {
      "model": "gpt-3.5-turbo-1106",
      "name": "GPT35-1106",
      "maxContext": 1600,
      "maxResponse": 4000,
      "price": 0
    }
  ],
  "VectorModels": [
    {
      "model": "text-embedding-ada-002",
      "name": "Embedding-2",
      "price": 0.2,
      "defaultToken": 700,
      "maxToken": 3000
    }
  ],
  "AudioSpeechModels": [
    {
      "model": "tts-1",
      "name": "OpenAI TTS1",
      "price": 0,
      "voices": [
        {"label": "Alloy", "value": "alloy", "bufferId": "openai-Alloy"},
        {"label": "Echo", "value": "echo", "bufferId": "openai-Echo"},
        {"label": "Fable", "value": "fable", "bufferId": "openai-Fable"},
        {"label": "Onyx", "value": "onyx", "bufferId": "openai-Onyx"},
        {"label": "Nova", "value": "nova", "bufferId": "openai-Nova"},
        {"label": "Shimmer", "value": "shimmer", "bufferId": "openai-Shimmer"}
      ]
    }
  ],
  "WhisperModel": {
    "model": "whisper-1",
    "name": "Whisper1",
    "price": 0
  }
}

5. Start Containers

docker-compose pull
docker-compose up -d
Check container status with docker ps .

6. Access FastGPT UI

Open a browser and navigate to http://127.0.0.1:3000 (or host_ip:3000 on a remote server). Default login credentials are:

Username: root Password: the value of DEFAULT_ROOT_PSW defined in

docker-compose.yml

Building a Knowledge Base

Create Knowledge Base

After logging in, click “New Knowledge Base” and give it a name (e.g., “Open‑Source Tech Stack”).

Import Documents

Use the “File Import” option to upload files. FastGPT automatically converts the files into vector embeddings. Enabling “direct segmentation” splits text into sentence‑level chunks; the default prompt template works without a custom QA template.

Link External Training Data

Provide URLs of source articles; FastGPT will fetch and index them.

https://mp.weixin.qq.com/s/1GD8eKrxJWXdgS3OKR4VHQ
https://mp.weixin.qq.com/s/BFdfDXHavZ_jZwVaFq2duQ
https://mp.weixin.qq.com/s/mNhMCzUtLUKrIzqSVa-qZA
https://mp.weixin.qq.com/s/n4n-0UCWJW9u2N1ca3HisQ
https://mp.weixin.qq.com/s/WXAPxHYteX7h1Hu73KEnFQ
https://mp.weixin.qq.com/s/chI8IbenaMFejvS7blLsBw

Using the Knowledge Base

Create Application

Each knowledge base must be bound to an application. Create a new app and select the previously created knowledge base.

Test Conversation

Use the built‑in preview panel to ask questions. FastGPT retrieves relevant passages, displays source links, and allows direct navigation to the original articles.

Key Configuration Details

PostgreSQL (pgvector) image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0, exposed port 5432.

MongoDB image: mongo:5.0.18, exposed port 27017.

FastGPT image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest, exposed port 3000.

Important environment variables: DEFAULT_ROOT_PSW, OPENAI_BASE_URL, CHAT_API_KEY, MONGODB_URI, PG_URL, plus token keys for authentication.

Volumes map persistent data directories ( ./pg/data, ./mongo/data) and the configuration file ( ./config.json:/app/data/config.json).

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LLMKnowledge BaseAI deploymentDocker ComposeFastGPT
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.