See this article:
You need to build Caddy with the DNS plugin added. See the docs on Docker, the “Adding custom Caddy modules” section in particular.