Understanding Docker Sandboxes for Upstream Proxy Settings
Most corporate networks do not let workstations talk to the internet directly. Traffic goes through an HTTP proxy, a SOCKS5 gateway, or a PAC file that picks a proxy per destination, and often the proxy also inspects TLS. If you run AI coding agents inside Docker Sandboxes on such a network, the sandbox has to follow the same path out. The Docker docs page Configure an upstream proxy explains how the sbx CLI handles this. This post walks through that guide with verified commands, explains the precedence rules that decide which proxy wins, and covers what changes when you work with Cloud Sandboxes.
One point to fix in your head early: an upstream proxy is not the same thing as the sandbox network policy. The network policy decides which destinations a sandbox may reach. The upstream proxy decides how the allowed traffic gets there. You configure them separately, and changing one never changes the other.
Note that the docs mark upstream proxy support as experimental. Setting names, PAC and SOCKS5 support, and authentication behavior can change, so check the guide before you script anything permanent.
Prerequisites
You need the sbx CLI installed. According to the install page, Docker Desktop and Docker Engine are not required. Supported hosts are:
- macOS Sonoma 14 or later on Apple silicon (install with Homebrew from the
docker/taptap) - Windows 11 on a 64-bit Intel or AMD CPU, with Windows Hypervisor Platform enabled for local sandboxes (install with
winget install -h Docker.sbx) - Ubuntu 24.04 or later on x86_64 or Arm64, with KVM enabled and your user in the
kvmgroup for local sandboxes - The address of your corporate proxy or PAC file, plus credentials if the proxy requires them
- Your organization’s root CA certificate in PEM format (.crt) if the proxy inspects HTTPS
Two kinds of outbound traffic
Docker Sandboxes produces two separate streams of outbound traffic, and each can use a different proxy:
- Sandbox traffic: anything an agent or tool does over the network from inside a local sandbox, such as calling a model API, cloning a repo, or installing packages.
- Daemon and host CLI traffic: the local daemon’s own requests (image pulls, telemetry, feature flags) plus host CLI calls such as
sbx login,sbx diagnose --upload, cloud commands,sbx move, the TUI, and cloud SSH.
Out of the box you do not need to configure anything. Both streams follow your operating system proxy settings, including a PAC URL if your OS has one. On macOS and Windows, sbx watches the OS setting while it runs, so switching Wi-Fi networks, connecting a VPN, or an updated PAC file is picked up without a restart. If the OS has no proxy, traffic goes direct.
Set the proxy explicitly with sbx settings
When the OS default is not what you want, override it with sbx settings set. There are three keys: proxy for both streams, proxy.sandbox for sandbox traffic only, and proxy.daemon for daemon and CLI traffic only.
# Route both kinds of traffic through an HTTP proxy
sbx settings set proxy http://proxy.corp:3128
# Send only sandbox traffic through a SOCKS5 proxy
sbx settings set proxy.sandbox socks5://proxy.corp:1080
# Let daemon traffic go direct
sbx settings set proxy.daemon direct
The value can take several forms:
| Value | Meaning |
|---|---|
| (unset) | Fall back to the wider scope, then environment variables, then the OS proxy |
http://host:port or https://host:port | HTTP or HTTPS proxy |
socks5://host:port | SOCKS5 proxy, DNS resolved locally |
socks5h://host:port | SOCKS5 proxy, DNS resolved by the proxy |
pac+http://host/proxy.pac, pac+https://host/proxy.pac, file:///path/proxy.pac | PAC (proxy auto-config) file |
system | Force the OS system proxy |
direct | Force a direct connection |
The socks5 versus socks5h difference matters on split-horizon DNS networks. If internal hostnames only resolve on the proxy side, use socks5h so the proxy does the lookup. A PAC file or the OS proxy can be pinned the same way:
sbx settings set proxy pac+https://host/proxy.pac
sbx settings set proxy system
To inspect what is in effect, use the read side of the settings commands. sbx settings ls lists every known setting with a SOURCE column (default, envvar, or override) and a RESTART column that flags settings needing a daemon restart. sbx settings get --json prints the full record for one key, including where the value came from.
sbx settings ls
sbx settings get --json proxy.daemon
# Drop an override and fall back to the wider scope
sbx settings unset proxy.daemon
Exclude internal destinations with no_proxy
Exclusion lists follow the same three scopes. Each accepts a comma separated list of hosts, domain suffixes, IP addresses, or CIDR ranges. A value of * bypasses the proxy for everything.
# Both kinds of traffic
sbx settings set no_proxy "*.internal.corp,10.0.0.0/8"
# Sandbox traffic only
sbx settings set no_proxy.sandbox "*.svc.cluster.local"
# Daemon traffic only
sbx settings set no_proxy.daemon "registry.internal"
A practical pattern: keep your internal registry on no_proxy.daemon so image pulls stay on the LAN, and keep cluster-internal service names on no_proxy.sandbox so agents can reach dev services without hairpinning through the proxy.
Environment variables and precedence
Because sbx runs from your shell, it honors the usual HTTP_PROXY, HTTPS_PROXY, and NO_PROXY variables (upper or lower case). They apply to both streams only when no proxy or no_proxy setting exists. There are also two sandbox-only variables, DOCKER_SANDBOXES_PROXY and DOCKER_SANDBOXES_NO_PROXY, which are the environment form of proxy.sandbox and no_proxy.sandbox and never touch daemon traffic.
For each stream, the first match in this list wins:
- The scope-specific value:
proxy.sandboxorDOCKER_SANDBOXES_PROXYfor sandbox traffic,proxy.daemonfor daemon traffic - The shared
proxysetting HTTP_PROXYorHTTPS_PROXYfrom the shell- The OS system proxy (the default)
- Direct
The matching exclusion list (no_proxy.<scope> first, then no_proxy) applies to whichever proxy was chosen. So if proxy points at a shared proxy and proxy.sandbox is direct, sandboxes connect directly while the daemon still uses the shared proxy:
sbx settings set proxy http://proxy.corp:3128
sbx settings set proxy.sandbox direct
When changes take effect
This is where most confusion comes from, because different consumers resolve proxy settings at different times:
- Sandbox scope is resolved when a sandbox network proxy is created. New sandboxes pick up the change. Existing sandboxes keep their old upstream until you run
sbx daemon restart. Restarting a single sandbox is not enough. - Daemon scope is resolved once at daemon start, so it always needs
sbx daemon restart. - Host CLI clients read daemon-scoped settings on every invocation, so they see changes on the next command with no restart.
DOCKER_SANDBOXES_*variables are read from the daemon’s environment at start, so changing them also needs a daemon restart. If one of them is overriding a stored setting, unset the variable and restart the daemon.
sbx daemon restart
Cloud SSH and proxy authentication
Cloud SSH reaches the SSH gateway through the configured host proxy. Some proxies refuse that port. If your network allows direct SSH, skip the proxy for cloud SSH only:
sbx settings set proxy.sshDirect true
Other host CLI requests keep using the proxy, and the change applies on the next SSH connection without a restart. Set it back to false to route SSH through the proxy again.
For proxies that need authentication you have two options. Basic authentication works on every platform by putting credentials in the URL, in the form http://user:pass@host:port or socks5://user:pass@host:port. On Windows, proxies that only accept NTLM or Kerberos/Negotiate can use your Windows sign-in identity through SSPI. This is off by default and is not scoped, so it applies to both streams:
sbx settings set proxy.integratedAuth true
The useful security detail here: proxy authentication happens on the host side of the sandbox boundary, after the network policy has already been applied. No credential enters the sandbox, and the set of reachable destinations does not change. The setting has no effect on macOS or Linux.
Local Sandboxes vs Cloud Sandboxes
Everything above is about local sandboxes, the local daemon, and host CLI connections. The guide is explicit that these settings do not configure traffic that originates inside a cloud sandbox. What they do affect on the cloud side is your host talking to the cloud: cloud commands, sbx move, the TUI, and cloud SSH all ride on the daemon and CLI stream.
Egress from a cloud sandbox is controlled by Cloud network policy, a separate store with account-wide and per-sandbox rules. Local policy is not copied to the cloud. A typical starting point from that page:
sbx --cloud policy init deny-all
sbx --cloud policy allow network api.github.com:443
So the mental model is: on your laptop, the network policy filters and the upstream proxy carries; in the cloud, the cloud network policy filters and your corporate proxy is not in the path at all. See Local vs cloud sandboxes for the wider comparison.
Troubleshooting: TLS-inspecting proxies
If your proxy decrypts HTTPS, agent requests can fail with errors like self-signed certificate in certificate chain. The troubleshooting page recommends installing your organization root CA inside the sandbox. Use a PEM certificate with a .crt extension. For an existing sandbox:
sbx cp ./internal-ca.crt <sandbox-name>:/tmp/internal-ca.crt
sbx exec <sandbox-name> -- sudo install -m 0644 /tmp/internal-ca.crt /usr/local/share/ca-certificates/internal-ca.crt
sbx exec <sandbox-name> -- sudo update-ca-certificates
For repeatable setup, package the CA into a mixin kit and create sandboxes with it:
sbx run claude --kit ./internal-ca/
Do not point SSL_CERT_FILE or similar variables at only your internal CA. That replaces the system bundle and breaks the trust the credential proxy relies on. If calls still fail, run sbx policy log and read the PROXY column:
forward: the credential proxy terminates TLS with a certificate the sandbox already trusts. The internal CA is not needed on this path.forward-bypassandtransparent: traffic is passed to your upstream proxy without TLS termination, so the sandbox sees your corporate certificate. This is where the internal CA matters.
Also remember that containers started by the Docker Engine inside a sandbox have their own trust stores. They do not inherit the CA you installed in the sandbox, so Dockerfile downloads need the CA added to the build image too. Other quick checks: if an existing sandbox ignores a new proxy value, run sbx daemon restart; if a stored setting seems ignored, look for a DOCKER_SANDBOXES_PROXY variable overriding it with sbx settings ls.
Key takeaways
- Upstream proxy controls how allowed traffic leaves; network policy controls what is allowed. They are separate.
- By default,
sbxfollows the OS proxy and PAC configuration and tracks changes live on macOS and Windows. - Use
proxy,proxy.sandbox, andproxy.daemon(and matchingno_proxykeys) to override per stream. - Sandbox-scope changes reach existing sandboxes only after
sbx daemon restart; daemon-scope changes always need it. - Proxy credentials and Windows integrated auth stay on the host and never enter the sandbox.
- Upstream proxy settings do not govern egress from Cloud Sandboxes; use
sbx --cloud policyfor that. - The feature is experimental, so recheck the docs before automating it.
References
Source guide: Configure an upstream proxy (Docker Docs). Related pages: Docker Sandboxes troubleshooting, Cloud network policy, Local vs cloud sandboxes, Install Docker Sandboxes, sbx settings set reference, sbx settings ls reference, and sbx policy log reference.