Skip to content

Commit 6eee5ea

Browse files
authored
Merge pull request #24612 from dvdksn/sbx/access-host-services
sandboxes: document accessing host services via host.docker.internal
2 parents 7ee58ed + 7b0caa3 commit 6eee5ea

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

content/manuals/ai/sandboxes/troubleshooting.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ To allow all outbound traffic instead:
3434
$ sbx policy allow network "**"
3535
```
3636

37+
## Can't reach a service running on the host
38+
39+
If a request to `127.0.0.1` or a local network IP returns "connection refused"
40+
from inside a sandbox, the address is not routable from within the sandbox VM.
41+
See [Accessing host services from a sandbox](usage.md#accessing-host-services-from-a-sandbox).
42+
3743
## Docker authentication failure
3844

3945
If you see a message like `You are not authenticated to Docker`, your login

content/manuals/ai/sandboxes/usage.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,28 @@ A few things to keep in mind:
298298
must use `--unpublish 8080:3000`. Run `sbx ports my-sandbox` first if you
299299
used an ephemeral port and need to find the assigned host port.
300300

301+
## Accessing host services from a sandbox
302+
303+
Services running on your host are reachable from inside a sandbox using the
304+
hostname `host.docker.internal`.
305+
Use this instead of `127.0.0.1` or your machine's local network IP address,
306+
which are not routable from inside the sandbox.
307+
308+
The sandbox proxy translates `host.docker.internal` to `localhost` before
309+
forwarding the request, so you must add the `localhost` address with the
310+
specific port to your network policy allowlist:
311+
312+
```console
313+
$ sbx policy allow network localhost:11434
314+
```
315+
316+
Then use `host.docker.internal` in any configuration or request that points at
317+
the host service. For example, to verify connectivity from a sandbox shell:
318+
319+
```console
320+
$ curl http://host.docker.internal:11434
321+
```
322+
301323
## What persists
302324

303325
While a sandbox exists, installed packages, Docker images, configuration

0 commit comments

Comments
 (0)