Pihole not resolving queries when upstream DNS is on localhost

That won't work with docker, unless you're running in host mode networking.

What is the address you have in Pi-hole for the upstream?

Edit: Ah, PIHOLE_DNS_1=127.0.0.1#5335. That won't work. That's pointing to the Pi-hole container and not the unbound container.