Managing Domain Entries
The following topics are discussed:
- Adding and removing extra DNS entries
- Resolving WeaveDNS entries from the Host
- Hot-swapping Service Containers
- Configuring a Custom TTL
Adding and Removing Extra DNS Entries
If you want to give the container a name in DNS other than its
hostname, you can register it using the dns-add
command. For example:
$ C=$(docker run -ti alpine:latest)
$ weave dns-add $C -h pingme2.weave.local
You can also use dns-add
to add the container’s configured hostname
and domain simply by omitting -h <fqdn>
, or specify additional IP
addresses to be registered against the container’s hostname e.g.
weave dns-add 10.2.1.27 $C
.
The inverse operation can be carried out using the dns-remove
command:
$ weave dns-remove $C
By omitting the container name it is possible to add/remove DNS records that associate names in the weaveDNS domain with IP addresses that do not belong to containers, e.g. non-weave addresses of external services:
$ weave dns-add 192.128.16.45 -h db.weave.local
Note that such records get removed when stopping the weave peer on which they were added.
Resolving WeaveDNS Entries From the Host
You can resolve entries from any host running weaveDNS with weave
dns-lookup
:
host1$ weave dns-lookup pingme
10.40.0.1
Hot-swapping service containers
If you would like to deploy a new version of a service, keep the old one running because it has active connections but make all new requests go to the new version, then you can simply start the new server container and then remove the entry for the old server container. Later, when all connections to the old server have terminated, stop the container as normal.
Configuring a custom TTL
By default, weaveDNS specifies a TTL of 30 seconds in responses to DNS
requests. However, you can force a different TTL value by launching
weave with the --dns-ttl
argument:
$ weave launch --dns-ttl=10
This will shorten the lifespan of answers sent to clients, so you will be effectively reducing the probability of them having stale information, but you will also be increasing the number of request this weaveDNS instance will receive.
See Also