docker-compose.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. # No fixed container_name: the container is named after the compose
  24. # project (e.g. <project>-unbound-1), so the template can be run side by
  25. # side with a test instance (project "unbound-sec-test") without
  26. # colliding with a production container of the same name.
  27. volumes:
  28. # Drop-ins only: *.conf files here are included by the base config.
  29. # Kept separate from config/ (the base config source) so the base
  30. # config is not inside /config — that would be a recursive include.
  31. # The directory starts empty; add e.g. forward-records.conf.
  32. - "./conf.d:/config:ro"
  33. # RFC5011 root trust anchor: persistent across restarts. Initialized
  34. # once by the entrypoint (from the dnssec-root package); afterwards
  35. # unbound maintains the file itself (learned keys, rollover state).
  36. # Named volume -> initialized with the image's /var/unbound ownership
  37. # (uid 1500), so the non-root user can write to it.
  38. - "unbound_anchor:/var/unbound"
  39. read_only: true
  40. tmpfs:
  41. - /tmp
  42. - "/run/unbound:uid=1500,gid=1500"
  43. security_opt:
  44. - no-new-privileges:true
  45. cap_drop:
  46. - ALL
  47. deploy:
  48. resources:
  49. limits:
  50. cpus: "1.0"
  51. memory: 512M
  52. pids: 100
  53. restart: always