There is an even easier solution that worked for me (and solved another problem too):
In your docker-compose.yml change
ports:
- 53:53/tcp
- 53:53/udp
to this
ports:
- 192.168.X.X:53:53/tcp
- 192.168.X.X:53:53/udp
Replace the X with the IP of the host where your Pi-Hole is running.
I got it from this Stackoverflow thread: docker-compose internal DNS server 127.0.0.11 connection refused - Stack Overflow