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

Docker容器部署聊天机器人响应延迟过高问题咨询

容器化聊天机器人响应延迟排查请求

我开发了一款聊天机器人应用,依赖项如下:

  • Python 3.10.10
  • Ollama 0.3.6
  • chromadb==0.5.3
  • streamlit==1.36.0
  • langchain_core==0.2.9
  • langchain_community==0.2.5
  • PyPDF2
  • pypdf==4.2.0
  • langdetect==1.0.9

为实现服务器部署,我完成了Docker容器化配置,创建了以下三个文件:

  • Dockerfile:包含所有依赖安装、端口暴露等配置
  • docker-compose.yml:包含Ollama容器与聊天机器人应用两个服务,Ollama服务会执行start.sh脚本
  • start.sh:用于启动容器内的Ollama服务并拉取模型

在本地执行docker-compose up --build完成容器化部署后,访问http://localhost:8501使用聊天机器人,上传文档并提问后,响应速度远慢于本地直接运行该应用的情况,请求排查此延迟问题。

附docker-compose.yml配置:

services:
  ollama:
    container_name: ollama_v5
    image: ollama/ollama:latest
    restart: unless-stopped
    volumes:
      - "./ollamadata:/root/.ollama"
      - "./start.sh:/start.sh"  # Mount the script into the container
    ports:
      - "11434:11434"
    entrypoint: /start.sh
    networks:
      - ollama_network

  chatbot:
    container_name: chatbot_v5
    build:
      context: ./    # The directory where Dockerfile and code are located
      dockerfile: Dockerfile
    restart: unless-stopped
    environment:
      - BASE_URL=http://ollama:11434     # Chatbot will access the Ollama API
    ports:
      - "8501:8501"                      
    depends_on:
      - ollama
    networks:
      - ollama_network

networks:
  ollama_network:
    driver: bridge

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 10:33:21