chat-ollama icon indicating copy to clipboard operation
chat-ollama copied to clipboard

docker 无法连通本地 ollama 服务

Open iaoxuesheng opened this issue 10 months ago • 7 comments

chatollama_1 | ChatOllama is unable to establish a connection with http://127.0.0.1:11434, please check: chatollama_1 | 1. Is Ollama server running ? (run ollama serve in terminal to start the server) chatollama_1 | 2. Can the server where ChatOllama is located connect to http://127.0.0.1:11434 ? chatollama_1 | Ollama: { host: 'http://127.0.0.1:11434', username: null, password: null } chatollama_1 | Error fetching instructions: PrismaClientKnownRequestError: chatollama_1 | Invalid prisma.instruction.findMany() invocation: chatollama_1 | chatollama_1 | chatollama_1 | The table main.Instruction does not exist in the current database. chatollama_1 | at In.handleRequestError (/app/.output/server/node_modules/@prisma/client/runtime/library.js:122:6854) chatollama_1 | at In.handleAndLogRequestError (/app/.output/server/node_modules/@prisma/client/runtime/library.js:122:6188) chatollama_1 | at In.request (/app/.output/server/node_modules/@prisma/client/runtime/library.js:122:5896) chatollama_1 | at async l (/app/.output/server/node_modules/@prisma/client/runtime/library.js:127:10871) chatollama_1 | at async listInstructions (file:///app/.output/server/chunks/routes/api/index.get.mjs:13:12) chatollama_1 | at async Object.handler (file:///app/.output/server/chunks/routes/api/index.get.mjs:20:24) chatollama_1 | at async Object.handler (file:///app/.output/server/chunks/runtime.mjs:2919:19) chatollama_1 | at async Server.toNodeHandle (file:///app/.output/server/chunks/runtime.mjs:3185:7) { chatollama_1 | code: 'P2021', chatollama_1 | clientVersion: '5.11.0', chatollama_1 | meta: { modelName: 'Instruction', table: 'main.Instruction' } chatollama_1 | }

iaoxuesheng avatar Apr 04 '24 02:04 iaoxuesheng

如果你的 ollama 不在 docker-compose 内启动,那是不能使用 127.0.0.1 访问的,你可以配置 IP 为本机试试

OLLAMA_HOST=192.168.0.10 ollama serve

recall704 avatar Apr 04 '24 04:04 recall704

ollama是自启动的吗,这个怎么取消掉,在执行时显示端口占有,kill掉会又被占有,感觉一直在自启动

如果你的 ollama 不在 docker-compose 内启动,那是不能使用 127.0.0.1 访问的,你可以配置 IP 为本机试试

OLLAMA_HOST=192.168.0.10 ollama serve

iaoxuesheng avatar Apr 04 '24 05:04 iaoxuesheng

如果你的 ollama 不在 docker-compose 内启动,那是不能使用 127.0.0.1 访问的,你可以配置 IP 为本机试试

OLLAMA_HOST=192.168.0.10 ollama serve

您好,感谢您的回复,我的docker-compose.yaml文件是这样:version: '3.1' services: chromadb: image: chromadb/chroma ports: - "8000:8000" restart: always volumes: - chromadb_data:/chroma/.chroma/index

chatollama: environment: - CHROMADB_URL=http://chromadb:8000 - OLLAMA_URL=http://192.168.59.273:11434 - DATABASE_URL=file:/app/sqlite/chatollama.sqlite image: 0001coder/chatollama:latest ports: - "3000:3000" restart: always volumes: - ~/.chatollama:/app/sqlite

volumes: chromadb_data: 然后也在配置了IP为本机,但是在chatollama里面好像还是在访问localhost:11434,然后还是报错找不到ollama

iaoxuesheng avatar Apr 04 '24 05:04 iaoxuesheng

如果 ollama 建置在本機的話,或許您可以使用 http://host.docker.internal:11434 來跳轉,這是 docker 提供容器連線到宿主機的特定 dns,可以參考看看。

sugky7302 avatar Apr 08 '24 03:04 sugky7302

In the Readme. have solution: host: http://host.docker.internal:11434/

pake35 avatar Apr 08 '24 09:04 pake35

我今天弄好了好久,使用 http://host.docker.internal:11434/ 也不行。

我的解决方法:

如果是 docker 启动的 chat-ollama 出现这种问题,可以修改 ollama 服务绑定的 ip 为 0.0.0.0,然后在 chat-ollama 里面的 settings 里面配置 http://[宿主机局域网ip]:11434。 具体修改 ollama 绑定 ip 的方法可参考官方文档:https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server

satrong avatar Apr 20 '24 04:04 satrong

设置里面的host应该配置为http://host.docker.internal:11434/

iwangbowen avatar Apr 20 '24 15:04 iwangbowen