You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

排查Semantic Kernel+Docker Compose部署ChromaDB的配置问题

Semantic Kernel 结合 ChromaDB Docker 部署时出现400错误

本地通过 chroma run --host localhost --port 8000 启动ChromaDB时,Semantic Kernel相关代码运行正常,但使用Docker Compose部署后,保存数据步骤出现400错误,创建集合操作可正常执行。

相关代码

// 初始化
var collectionName = "mydataMemory";
await chromaClient.CreateCollectionAsync(collectionName, cancellationToken);

// 保存记录
var chromaMemoryStore = new ChromaMemoryStore(chromaClient);
var memory = new SemanticTextMemory(chromaMemoryStore, textEmbeddingGenerationService);
await memory.SaveInformationAsync(collectionName, text, id, description, metadata, cancellationToken: cancellationToken);

注:metadata和description参数目前均为空。

错误日志

chroma_server-1  | INFO:     [23-02-2025] - "POST /api/v1/collections HTTP/1.1" 200
myapp-1    | info: Microsoft.SemanticKernel.Connectors.OpenAI.OpenAITextEmbeddingGenerationService[0]
myapp-1    |       Action: GenerateEmbeddingsAsync. OpenAI Model ID: text-embedding-ada-002.
chroma_server-1  | INFO:     [23-02-2025 - "GET /api/v1/collections/mydataMemory HTTP/1.1" 400
myapp-1    | fail: Microsoft.Extensions.Hosting.Internal.Host[9]
myapp-1    |       BackgroundService failed
myapp-1    |       Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 400 (Bad Request).
...

Docker Compose 配置

version: '3.9'

networks:
  net:
    driver: bridge

services:

  chroma_server:
    image: chromadb/chroma:latest
    volumes:
      - chroma-data:/chroma/chroma
    restart: unless-stopped
    ports:
      - "8000:8000"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8000/api/v2/heartbeat" ]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - net

  myapp:
    image: ${DOCKER_REGISTRY-}myapp
    build:
      context: .
      dockerfile: myapp/Dockerfile
    depends_on:
      chroma_server:
        condition: service_healthy
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - MyApp_API_KEY=${MyApp_API_KEY}
    networks:
      - net 

volumes:
  chroma-data:
    driver: local

补充说明

  • 代码在本地无容器环境运行正常
  • Docker环境中已将Chroma端点从 localhost:8000 修改为 http://chroma_server:8000
  • Docker Compose环境下创建集合操作正常,问题仅出现在保存数据步骤
  • 本地请求正常但容器环境返回400错误

更新日志(重命名Chroma服务后)

将Docker Compose中的chroma_server重命名为chroma后,错误依旧:

Pull complete 
 chroma Pulled 
 Network bot_net  Creating
 Network bot_net  Created
 Volume "bot_chroma-data"  Creating
 Volume "bot_chroma-data"  Created
 Container bot-chroma-1  Creating
 Container bot-chroma-1  Created
 Container bot-myapp-1 Creating
 Container bot-myapp-1 Created
Attaching to chroma-1, telegrambot-1
chroma-1       | Starting 'uvicorn chromadb.app:app' with args: --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
...
chroma-1       | INFO:     [01-03-2025 ..] 172.X.Y.Z:12345 - "GET /api/v1/collections/myDataMemory HTTP/1.1" 400
myapp-1 | fail: Microsoft.Extensions.Hosting.Internal.Host[9]
myapp-1 |       BackgroundService failed
myapp-1 |       Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 400 (Bad Request).
...

内容的提问来源于stack exchange,提问作者dododo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 05:53:15