docker-compose.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Hardened run template for unbound-sec
  2. #
  3. # Security options enabled here:
  4. # - read_only root filesystem (writable paths via tmpfs)
  5. # - no-new-privileges (process can't gain privileges via setuid/setgid)
  6. # - cap_drop ALL (non-root user: no capabilities anyway)
  7. # - CPU/memory/PID limits (abusive recursive lookups are bounded)
  8. #
  9. # Network: NO ports are published. The resolver is meant to run inside a
  10. # shared Docker network that its clients join (e.g. the Pi-hole network).
  11. # If you need LAN access, publish on a specific host address only:
  12. # ports:
  13. # - "192.168.0.1:5053:5053/udp"
  14. # - "192.168.0.1:5053:5053/tcp"
  15. #
  16. # Usage: docker compose up -d
  17. name: unbound-sec
  18. volumes:
  19. unbound_anchor:
  20. services:
  21. unbound:
  22. image: unbound-sec:latest
  23. container_name: unbound
  24. volumes:
  25. # Drop-ins only: *.conf files here are included by the base config.
  26. # Kept separate from config/ (the base config source) so the base
  27. # config is not inside /config — that would be a recursive include.
  28. # The directory starts empty; add e.g. forward-records.conf.
  29. - "./conf.d:/config:ro"
  30. # RFC5011 root trust anchor: persistent across restarts. Initialized
  31. # once by the entrypoint (from the dnssec-root package); afterwards
  32. # unbound maintains the file itself (learned keys, rollover state).
  33. # Named volume -> initialized with the image's /var/unbound ownership
  34. # (uid 1500), so the non-root user can write to it.
  35. - "unbound_anchor:/var/unbound"
  36. read_only: true
  37. tmpfs:
  38. - /tmp
  39. - "/run/unbound:uid=1500,gid=1500"
  40. security_opt:
  41. - no-new-privileges:true
  42. cap_drop:
  43. - ALL
  44. deploy:
  45. resources:
  46. limits:
  47. cpus: "1.0"
  48. memory: 512M
  49. pids: 100
  50. restart: always