虚拟机上用 docker 装了 dify 。大模型装在 windows 宿主机上。调不通 #123

Open
opened 2026-02-16 11:19:48 -05:00 by yindo · 2 comments
Owner

Originally created by @Ucer on GitHub (Mar 23, 2025).

##项目环境

  • 在 windows11 上通过 virtualbox 装了虚拟机
  • 在虚拟机上通过 docker composer 装了 dify

问题说明

无法配置 ollama 模型,连接超时

Image
在 windows 上 ollama 服务 正常
Image

windows 防火墙已放开,进入虚拟机容器能正常访问http://192.168.0.104:11434

Image

Originally created by @Ucer on GitHub (Mar 23, 2025). ##项目环境 - 在 windows11 上通过 virtualbox 装了虚拟机 - 在虚拟机上通过 docker composer 装了 dify ## 问题说明 无法配置 ollama 模型,连接超时 ![Image](https://github.com/user-attachments/assets/057fe8cd-91ed-44a1-8de5-61212a25d9f6) 在 windows 上 ollama 服务 正常 ![Image](https://github.com/user-attachments/assets/1830d911-2b00-4e36-978f-5de3e9175af8) windows 防火墙已放开,进入虚拟机容器能正常访问http://192.168.0.104:11434 ![Image](https://github.com/user-attachments/assets/854a7114-84ad-48f2-94dc-72715847af51)
yindo added the bug label 2026-02-16 11:19:48 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 23, 2025):

@Ucer 你好!我是Dosu,一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。我会在这里帮助你,等待人类维护者。

I found similar open issues that might help resolve your connection timeout problem when configuring the Ollama model in a Docker environment on a virtual machine:

  1. Issue with Timeout Error: One solution suggests ensuring that the Ollama service is accessible from the Docker container. This involves setting the OLLAMA_HOST environment variable to 0.0.0.0 to expose the service to the network. Additionally, replace localhost with host.docker.internal in your service configuration to ensure Docker can access the host network [1].

  2. Connection Error on Windows: Another solution for a similar issue on Windows involves replacing localhost with host.docker.internal to allow the Docker container to access services running on the host machine. Ensure the OLLAMA_HOST environment variable is set to 0.0.0.0 [2].

To resolve your issue, try the following steps:

  • Replace localhost: Use host.docker.internal instead of localhost in your configuration to allow the Docker container to access the Ollama service running on the Windows host.

  • Set Environment Variable: Ensure the OLLAMA_HOST environment variable is set to 0.0.0.0 on your Windows host to bind the service to all network interfaces.

These steps should help you configure the Ollama model and resolve the connection timeout issue.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 23, 2025): <!-- Greeting --> @Ucer 你好!我是[Dosu](https://dosu.dev),一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。我会在这里帮助你,等待人类维护者。 <!-- Answer --> I found similar open issues that might help resolve your connection timeout problem when configuring the Ollama model in a Docker environment on a virtual machine: 1. **Issue with Timeout Error**: One solution suggests ensuring that the Ollama service is accessible from the Docker container. This involves setting the `OLLAMA_HOST` environment variable to `0.0.0.0` to expose the service to the network. Additionally, replace `localhost` with `host.docker.internal` in your service configuration to ensure Docker can access the host network <sup>[[1]](https://github.com/langgenius/dify-docs/issues/647)</sup>. 2. **Connection Error on Windows**: Another solution for a similar issue on Windows involves replacing `localhost` with `host.docker.internal` to allow the Docker container to access services running on the host machine. Ensure the `OLLAMA_HOST` environment variable is set to `0.0.0.0` <sup>[[2]](https://github.com/langgenius/dify-docs/issues/488)</sup>. To resolve your issue, try the following steps: - **Replace `localhost`**: Use `host.docker.internal` instead of `localhost` in your configuration to allow the Docker container to access the Ollama service running on the Windows host. - **Set Environment Variable**: Ensure the `OLLAMA_HOST` environment variable is set to `0.0.0.0` on your Windows host to bind the service to all network interfaces. These steps should help you configure the Ollama model and resolve the connection timeout issue. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/133ac3bd-b4da-48d3-9b5f-b4a3a16f267d?feedback_type=other)</sup>
Author
Owner

@ccHonglin commented on GitHub (Apr 1, 2025):

我有相同的问题,我ollama部署在windows中,dify通过wsl2中的docker安装,无法访问ollama的模型

@ccHonglin commented on GitHub (Apr 1, 2025): 我有相同的问题,我ollama部署在windows中,dify通过wsl2中的docker安装,无法访问ollama的模型
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-docs-archived#123