I build in containers but nothing to do with Docker. I make a build environment with pacstrap (Arch) or debootstrap (Debian) and use systemd-nspawn to use it as a container.
Prevents it accidentally removing all my files and avoids unintended dependencies / environment issues.
I really like that the AOSP build system is essentially doing this by itself by providing prebuilts for all of the dependencies and isolating the build with namespaces. Can also rebuild those prebuilts in a reproducible way when they've set it properly. Works really nicely.