0 cache insertions

Hi all!
I have a very similar case to DNS Cache not working which was never resolved, however I use the official pihole docker image.
I used docker to set up the official pihole image and the official unbound image and gave pihole unbound as it's upstream server. When I did this, the cache insertions stopped happening. When I set it back to any other upstream provider, the caching starts again.
Here's my docker-compose.yml file:

version: '3'
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    # For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      #- "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
      - "80:80/tcp"
    environment:
      TZ: 'Europe/Budapest'
      # WEBPASSWORD: 'set a secure password here or it will be random'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
      #- './etc-pihole-updatelists/:/etc/pihole-updatelists/'    
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN # Recommended but not required (DHCP needs NET_ADMIN)      
    restart: unless-stopped
    dns:
      - 8.8.8.8
  unbound:
    container_name: unbound
    image: mvance/unbound:latest
    ports: 
      - "5053:53/udp"
      - "5053:53/tcp"
    volumes:
      - './etc-unbound:/etc/unbound/'
    restart: unless-stopped

My debug token is https://tricorder.pi-hole.net/vyjVTRO5/

What is the status of the cache with this command:

echo ">cacheinfo >quit" | nc localhost 4711

How do I do it with a docker container?
I tried to run the command, however I couldn't get an output. I tried to expose the container's port 4711 (both tcp and udp), and run it again... Nothing. I tried echo ">cacheinfo >quit" | docker exec pihole nc localhost 4711 and the process just hang there for hours without any output.
Here's a screenshot for clarification:

Try run a bash shell first eg:

sudo docker exec -it <CONTAINER_NAME> bash

The only answer I get is:
OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown
Basic research lead me to this bug: OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown · Issue #43969 · moby/moby · GitHub
So sadly the debugging is postponed until I figure out how to use the workaround...

Restarting the container stack fixed the issue (temporarily?). The results of echo ">cacheinfo >quit" | nc localhost 4711 is

cache-size: 10000
cache-live-freed: 0
cache-inserted: 0
ipv4: 2
ipv6: 7
srv: 0
cname: 0
ds: 0
dnskey: 0
other: 8
expired: 0
immortal: 17

None of these numbers go up if I load new sites.
Then I found this: unbound.conf(5) — Unbound 1.14.0 documentation
Guess what, setting the value to yes (and restarting the containers once more) did something as load times appear to reduce after first loading a page (or I'm imagining it...), but when I rerun the commands above I still got the same response.

Please also post a new debug token - your original one has expired. :wink:

Here it is: https://tricorder.pi-hole.net/yT08wdLd/

I might have figured it out by accident: it's performance.
I was having other DNS issues, so I turned off unbound and put 1.1.1.1 in its place, and suddenly resolution & blocked rates skyrocketed. Thinking back, there were a lot of "Retired" entries and sometimes got the "Maximum concurrent DNS queries" warning.
What I think happened is that unbound couldn't keep up with all the 20+ devices on my network (of four people most of the time), and on our devices DNS kept timing out. They turned then to the secondary DNS provider, which is my router. This would explain why load times were abyssal.
At the same time, unbound also timed out, dropping the query and never sending a response and PiHole had nothing to cache.
I'm not 100% sure if the root cause is timing out, or a misconfiguration of my containers or an issue with the host (docker and virtual network interfaces); but now it works, be it less private.

This is extremely likely to be the case. If Pi-hole can handle the load, so can unbound.

Since unbound seems to be the limiting factor here, there was likely a problem with your unbound installation or configuration.