Self-Hosting a UniFi Controller: An Empty Package Repo and a DNS Server That Wasn't Ours
A managed switch has no meaningful standalone config, so we built a controller as the lab's first real Terraform-managed container. Along the way: an inherited DNS server the container could not reach, a vendor repository that published nothing, and a Java version Debian does not ship.

Key Architectural Takeaways
- Terraform providers can copy the hypervisor's resolver into new containers; set DNS explicitly in the resource.
- Check the vendor's repository metadata directly; an index can be empty while update reports success.
- Verify a dependency exists for your OS release before adding its repository.
The challenge
We had found a managed switch on the network, but a switch of this kind has almost no configuration of its own. VLANs, port profiles and PoE are pushed to it by a controller, and we had none. Hand-configuring the switch over SSH would have meant no real configuration, or settings a later adoption would overwrite. So we built the controller.
Placement and the first Terraform resource
We chose a dedicated container created by Terraform over Docker on an existing host. It isolates the controller from our DNS host, and the hypervisor had far more memory headroom. The ID and address were checked against the firewall's live ARP table and DHCP leases, not assumed. It was the first Terraform-managed resource we kept: an earlier test container had only proved the create-and-destroy path, and its declaration was removed outright so it would not be recreated on the next apply.
Problem 1: DNS that hung
SSH worked, since that is same-subnet. But apt-get update hung for minutes. The container's resolver pointed at the Tailscale MagicDNS proxy address. The Terraform provider had copied the hypervisor's own resolv.conf into the container, and the hypervisor uses MagicDNS. This container is not on the tailnet, so the address simply never answered, and lookups hung instead of failing.
We fixed it in Terraform with an explicit DNS block (the firewall as server, our internal domain), checking the provider's real schema first rather than guessing field names. Making the fix in the resource means a rebuilt container cannot silently reintroduce the hang.
Problem 2: the vendor repository was empty
The install guides all describe adding the vendor's apt repository. apt-get update succeeded, but apt-cache policy showed no package. Reading the repository's Release file directly showed its package index at exactly zero bytes, the MD5 of the empty string. This was not our configuration: the "stable" channel was publishing nothing. We switched to a pinned direct package download with a locally computed checksum, since the vendor publishes none, and removed the dead repository tasks rather than leaving them behind.
Problem 3: a Java version Debian does not ship
This controller release needs Java 25, which Debian 12 does not carry. The first install failed cleanly on the unmet dependency. We confirmed that Eclipse Temurin publishes that JRE for this release by reading its real package index before adding its repository with a modern signed-by keyring, then reran the install.
Hardening and baseline
A fresh Debian container has no sudo and connects as root, so the baseline playbook's privilege escalation needed one manual apt-get install sudo first. After the baseline, SSH was key-only with password authentication off and root login restricted to keys.
Takeaway
Containers inherit assumptions from the host that built them. Make network settings explicit, read repository metadata instead of trusting an update that printed no error, and confirm every dependency exists for your release before you build the plan around it.
Some of what's described here is a design that hasn't been fully tested yet; those parts say so in the text.