Files
nexus/wiki/concepts/DockerHostNetworking.md
2026-05-03 05:42:12 +08:00

42 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "DockerHostNetworking"
type: concept
tags:
- "docker"
- "networking"
- "container"
sources: []
last_updated: 2026-04-20
---
## Overview
DockerHostNetworking 是 Docker 容器访问宿主机网络服务的方式。默认情况下,容器内的 `localhost` 指向容器自身而非宿主机,因此需要特殊配置才能让容器访问运行在宿主机上的服务。
## Why It Matters for Hermes Agent + Open WebUI
Open WebUI 运行在 Docker 容器中Hermes Agent API Server 运行在宿主机上(端口 8642。容器内必须通过特殊方式访问宿主机端口。
## Options
### Option 1: host.docker.internal推荐 macOS/Windows
```bash
docker run --add-host=host.docker.internal:host-gateway ...
# 访问http://host.docker.internal:8642/v1
```
### Option 2: Host NetworkingLinux
```bash
docker run --network=host ...
# 访问http://localhost:8642/v1
```
### Option 3: Docker Bridge IP
```bash
# 先查询docker inspect bridge | grep Gateway
docker run -e OPENAI_API_BASE_URL=http://172.17.0.1:8642/v1 ...
```
## See Also
- [[open-webui-hermes-agent]]