fix(dns): resolve public hostnames from spawned containers (#1168)

Lambda/CodeBuild containers get Floci's IP as their only DNS, so all
public-name resolution flows through Floci's embedded UDP/53 forwarder.
The forwarder read responses into a hardcoded 512-byte buffer, silently
truncating larger EDNS0 responses (e.g. CDN-backed hosts), so public
lookups failed inside Lambda with ENOTFOUND/EBUSY.

- Enlarge the forwarder receive buffer to 4096 bytes (EDNS0).
- Forward across an ordered upstream list (resolv.conf + configurable
  public fallbacks), returning the first valid response; warn when all
  upstreams fail instead of dropping the response silently.
- Append configurable fallback resolvers (default 8.8.8.8, 8.8.4.4)
  after Floci's IP on spawned containers' HostConfig.Dns, controllable
  via floci.dns.container-fallback-* / FLOCI_DNS_CONTAINER_FALLBACK_*.

Closes #1110
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-06-04 00:42:38 -05:00
1 parent 7128758a63
commit 2d30641479
10 files changed
+401 -24

No files matched your search

+18 -1
View File
@@ -223,12 +223,29 @@ on its container IP. All Lambda containers launched by Floci are configured to
use it as their DNS resolver. The embedded DNS server:
- Resolves `*.localhost.floci.io` → Floci's Docker network IP
- Forwards all other queries to the upstream resolver from `/etc/resolv.conf`
- Forwards all other queries to the upstream resolver(s) from `/etc/resolv.conf`,
falling back to public resolvers so **public hostnames** (e.g.
`business-api.tiktok.com`) resolve from inside Lambda containers
No extra configuration or `cap_add` is needed — Docker containers have
`CAP_NET_BIND_SERVICE` in their default capability set, so Floci (running as a
non-root user) can bind UDP/53 without any changes to your Compose file.
!!! note "Resolving public hostnames from Lambda"
A Lambda whose handler reaches a public host (`fetch()`/HTTPS to e.g.
`business-api.tiktok.com`) resolves it through Floci's embedded DNS. As a
safety net, Floci also appends configurable public resolvers (default
`8.8.8.8`, `8.8.4.4`) after its own IP on each spawned container's DNS list,
so name resolution still works if the embedded forwarder cannot answer.
Tune or disable this for offline / locked-down networks where those resolvers
are blocked:
```bash
FLOCI_DNS_CONTAINER_FALLBACK_SERVERS=1.1.1.1,1.0.0.1 # use different resolvers
FLOCI_DNS_CONTAINER_FALLBACK_ENABLED=false # inject only Floci's DNS
```
!!! tip "Docker Compose service names"
If Floci runs as a Docker Compose service, set `FLOCI_HOSTNAME` to the
service name, for example `FLOCI_HOSTNAME=floci`. When no explicit Lambda