DockNS & Docker Swarm
DockNS can be used with Docker Swarm in two ways.
Option 1 - Service labels
When using Swarm, applications are deployed using services, which can have labels attached to them. DockNS has the ability to read these labels to create records just like it would with regular container labels. The Swarm services is enabled by default, but can be disabled by setting include_swarm_services to false.
When using service labels with DockNS, DockNS must connect to a manager node in the cluster. Worker nodes do not have access to the service definitions which includes labels.
Additionally, only one DockNS instance should manage service labels, even if there are multiple manager nodes. Multiple DockNS instances will cause collisions and produce error messages in the logs.
Option 2 - Container labels
When creating a Swarm service, instead of setting DockNS's labels on the service itself, you can attach them to the containers instead. This will DockNS's regular container detection to find the labels and create records.
There are a few caveats when using container labels on Swarm services:
DockNS needs to connect to every Docker daemon in the cluster.
Services with replicas can cause collisions between DockNS instances.
Using service labels avoids these issues.