You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
将 Ollama 监听从 127.0.0.1 修改为 0.0.0.0,可通过新增 OLLAMA_HOST 环境变量完成,而当前网络架构是 Windows ---NAT1--- WSL ---NAT2--- podman 容器。故只需要添加 Windows 主机 NAT1 的网卡地址即可。
具体如下图:
Translation:
Because Windows platforms typically run docker/podman via solutions like WSL, while Ollama on Windows can be directly downloaded as a Windows binary, the following scenario arises: Ollama runs on the Windows host, which manages the WSL subnet via NAT. Podman runs within WSL. The requirement is for the host to access port 8080 of the container, and the container to access port 11434 of the host.
WSL commonly uses NAT mode, rendering the docker/podman --net host mode ineffective for container access to the host. This means the solution mentioned in the README won't work. Since docker/podman can map host port 3000 to container port 8080 using -p 3000:8080 (via the podman bridge, which is a NAT network), the only remaining problem is enabling the container to access host port 11434.
Due to NAT between Windows and WSL, and another layer of NAT between WSL and the podman container (two layers of NAT), running the container in --net host mode won't bypass the Windows-to-WSL NAT. The following solution is proposed:
Change Ollama's listening address from 127.0.0.1 to 0.0.0.0. This can be achieved by adding the OLLAMA_HOST environment variable. Given the current network architecture: Windows ---NAT1--- WSL ---NAT2--- podman container, only the Windows host's NAT1 network interface address needs to be added.
This discussion was converted from issue #9472 on February 06, 2025 08:26.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
由于 Windows 平台使用 docker / podman 一般通过 WSL 等方案来实现,而 Windows 平台使用 Ollama 可以直接下载 Windows 端 Ollama 二进制程序。这就形成以下场景:Ollama 运行在 Windows 主机上,Windows 通过 NAT 网络管理 WSL 网段,podman 运行在 WSL 上。而需求是主机访问容器的 8080 端口,容器需要访问主机的 11434 端口。
WSL 常用网络模式为 NAT,这就使 docker / podman 的 --net host 主机模式在容器访问主机失效,也就是说 README 文档中提及的解决方案是不起作用的。由于 docker / podman 可以通过 -p 3000:8080 将主机的 3000 端口与容器的 8080 端口关联(通过 podman 建立的网桥,也就是一个 NAT 网络),所以只需要打通容器访问主机 11434 端口的问题即可。
由于 Windows 到 WSL 存在 NAT,WSL 到 podman 容器也存在 NAT,也就是说存在两层 NAT,采用 --net host 主机模式运行容器也就无法突破 Windwos 到 WSL 的 NAT。可以采取下列方案解决:
将 Ollama 监听从 127.0.0.1 修改为 0.0.0.0,可通过新增 OLLAMA_HOST 环境变量完成,而当前网络架构是 Windows ---NAT1--- WSL ---NAT2--- podman 容器。故只需要添加 Windows 主机 NAT1 的网卡地址即可。
具体如下图:
Translation:
Because Windows platforms typically run docker/podman via solutions like WSL, while Ollama on Windows can be directly downloaded as a Windows binary, the following scenario arises: Ollama runs on the Windows host, which manages the WSL subnet via NAT. Podman runs within WSL. The requirement is for the host to access port 8080 of the container, and the container to access port 11434 of the host.
WSL commonly uses NAT mode, rendering the docker/podman
--net host
mode ineffective for container access to the host. This means the solution mentioned in the README won't work. Since docker/podman can map host port 3000 to container port 8080 using-p 3000:8080
(via the podman bridge, which is a NAT network), the only remaining problem is enabling the container to access host port 11434.Due to NAT between Windows and WSL, and another layer of NAT between WSL and the podman container (two layers of NAT), running the container in
--net host
mode won't bypass the Windows-to-WSL NAT. The following solution is proposed:Change Ollama's listening address from
127.0.0.1
to0.0.0.0
. This can be achieved by adding the OLLAMA_HOST environment variable. Given the current network architecture: Windows ---NAT1--- WSL ---NAT2--- podman container, only the Windows host's NAT1 network interface address needs to be added.A diagram illustrating this is shown below:
Beta Was this translation helpful? Give feedback.
All reactions