diff --git a/weave b/weave index c602e51d..b00eadcc 100755 --- a/weave +++ b/weave @@ -397,7 +397,17 @@ case "$COMMAND" in shift 1 create_bridge DNS_ARG=$(docker inspect --format '--dns {{ .NetworkSettings.IPAddress }}'" --link $DNS_CONTAINER_NAME:$DNS_CONTAINER_NAME" $DNS_CONTAINER_NAME 2>/dev/null) || true - CONTAINER=$(docker run $DNS_ARG -d "$@" | tail -n 1) + DNS_SEARCH_ARG="--dns-search=." + for arg in $@; do + case $arg in + --dns-search=*) + DNS_SEARCH_ARG="" + ;; + *) + ;; + esac; + done + CONTAINER=$(docker run $DNS_ARG $DNS_SEARCH_ARG -d "$@" | tail -n 1) with_container_netns $CONTAINER attach $CIDR >/dev/null tell_dns PUT $CONTAINER $CIDR echo $CONTAINER diff --git a/weavedns/README.md b/weavedns/README.md index 48998a5b..632a077f 100644 --- a/weavedns/README.md +++ b/weavedns/README.md @@ -19,7 +19,7 @@ $ weave run 10.1.1.25/24 -ti -h pingme.weave.local ubuntu $ shell1=$(weave run 10.1.1.26/24 -ti -h ubuntu.weave.local ubuntu) $ docker attach $shell1 -# ping pingme.weave.local +# ping pingme ... ``` @@ -27,6 +27,21 @@ The IP address supplied to `weave launch-dns` must not be used by any other container, and the supplied network must contain all application networks. +## Domain search paths + +If you don't supply a domain search path (with `--dns-search=`), +`weave run ...` will tell a container to look for "bare" hostnames, +like `pingme`, in its own domain. That's why you can just say `ping +pingme` above -- since the hostname is `ubuntu.weave.local`, it will +look for `pingme.weave.local`. + +If you want to supply other entries for the domain search path, you +will need *also* to supply the `weave.local` domain or subdomain: + +```bash +weave run 10.1.1.4/24 -ti --dns-search=weave.local --dns-search=local ubuntu +``` + ## Doing things more manually If a weaveDNS container is running, `weave run` will automatically @@ -53,6 +68,13 @@ $ weave attach 10.1.1.27/24 $shell2 This isn't very useful unless the container is also attached to the weave network (as in the last line above). +### Supplying the domain search path + +Again, when using `docker run`, you will usually want to supply a +domain search path so that you can use unqualified hostnames. Use +`--dns-search=.` to make the resolver use the container's domain, or +e.g., `--dns-search=weave.local` to make it look in `weave.local`. + ### Adding containers to DNS If DNS is started after you've attached a container to the weave @@ -84,6 +106,13 @@ $ dns_ip=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' weavedns) $ curl -X DELETE "http://$dns_ip:6785/name/$shell2/10.1.1.27" ``` +### Supplying `--dns-search=` + +By default, Docker will provide containers with a `/etc/resolv.conf` +that matches that for the host. In some circumstances, this may +include a DNS search path, which will break the nice "bare names +resolve" property above. + ## Present limitations * The server will not know about restarted containers, but if you