zh_CN/learn-more/use-cases/private-ai-ollama-deepseek-dify.md 文档疑问 #56

Closed
opened 2026-02-16 11:19:38 -05:00 by yindo · 1 comment
Owner

Originally created by @jrsnd on GitHub (Feb 10, 2025).

Image

在常见问题中,官方针对上述问题的Windows解决方案,似乎未能解决Ollama 服务在 Docker 容器中无法访问的问题。
经过本人实操,使用了macOS 环境配置方法,反倒解决了 Windows上Docker 部署时的连接错误。

**如果以上步骤无效,可以使用以下方法:

问题是在 docker 内部,你应该连接到 host.docker.internal,才能访问 docker 的主机,所以将 localhost 替换为 host.docker.internal 服务就可以生效了:

http://host.docker.internal:11434**

以上如有问题还请指正,盼复。

Originally created by @jrsnd on GitHub (Feb 10, 2025). ![Image](https://github.com/user-attachments/assets/b8571218-2abc-4ace-bf0c-dfb757f1ca55) 在常见问题中,官方针对上述问题的Windows解决方案,似乎未能解决Ollama 服务在 Docker 容器中无法访问的问题。 经过本人实操,使用了macOS 环境配置方法,反倒解决了 Windows上Docker 部署时的连接错误。 **如果以上步骤无效,可以使用以下方法: 问题是在 docker 内部,你应该连接到 host.docker.internal,才能访问 docker 的主机,所以将 localhost 替换为 host.docker.internal 服务就可以生效了: http://host.docker.internal:11434** 以上如有问题还请指正,盼复。
yindo added the bugquestion labels 2026-02-16 11:19:38 -05:00
yindo closed this issue 2026-02-16 11:19:38 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 10, 2025):

Hello, @jrsnd! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together!

To resolve the connection error when using Dify and Ollama in a Docker container on Windows, you should indeed replace localhost with host.docker.internal. This allows the Docker container to access services running on the host machine. The correct URL to use is:

http://host.docker.internal:11434

This change is necessary because localhost within a Docker container refers to the container itself, not the host machine. By using host.docker.internal, you can correctly route the connection to the host's network services. Additionally, ensure that the OLLAMA_HOST environment variable is set to 0.0.0.0 to allow connections from Docker [1][2].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Feb 10, 2025): <!-- Greeting --> Hello, @jrsnd! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together! <!-- Answer --> To resolve the connection error when using Dify and Ollama in a Docker container on Windows, you should indeed replace `localhost` with `host.docker.internal`. This allows the Docker container to access services running on the host machine. The correct URL to use is: ```bash http://host.docker.internal:11434 ``` This change is necessary because `localhost` within a Docker container refers to the container itself, not the host machine. By using `host.docker.internal`, you can correctly route the connection to the host's network services. Additionally, ensure that the `OLLAMA_HOST` environment variable is set to `0.0.0.0` to allow connections from Docker <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/learn-more/use-cases/private-ai-ollama-deepseek-dify.md)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/jp/learn-more/use-cases/private-ai-ollama-deepseek-dify.md)</sup>. <!-- 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/ad959239-78e7-4105-b40b-1354a241c836?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/ad959239-78e7-4105-b40b-1354a241c836?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/ad959239-78e7-4105-b40b-1354a241c836?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/ad959239-78e7-4105-b40b-1354a241c836?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ad959239-78e7-4105-b40b-1354a241c836?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/ad959239-78e7-4105-b40b-1354a241c836?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-docs-archived#56