Add --with-dns option to weave run

This commit is contained in:
Bryan Boreham committed 2014-11-24 20:14:01 +00:00
1 parent 5c76411e34
commit 42f0cb883a
2 files changed
+33 -21

No files matched your search

+26 -15
View File
@@ -6,7 +6,7 @@ usage() {
echo "weave launch [-password <password>] <peer> ..."
echo "weave launch-dns <cidr>"
echo "weave connect <peer>"
echo "weave run <cidr> <docker run args> ..."
echo "weave run [-with-dns] <cidr> <docker run args> ..."
echo "weave start <cidr> <container_id>"
echo "weave attach <cidr> <container_id>"
echo "weave detach <cidr> <container_id>"
@@ -402,21 +402,32 @@ case "$COMMAND" in
docker images --no-trunc | grep $DOCKERIMAGE | grep -v latest | tr -s ' ' | cut -d ' ' -f 2
;;
run)
[ $# -gt 0 ] || usage
validate_cidr $1
CIDR=$1
shift 1
[ $# -gt 1 ] || usage
create_bridge
DNS_ARG=$(docker inspect --format '--dns {{ .NetworkSettings.IPAddress }}'" --link $DNS_CONTAINER_NAME:$DNS_CONTAINER_NAME" $DNS_CONTAINER_NAME 2>/dev/null) || true
DNS_SEARCH_ARG="--dns-search=."
for arg in $@; do
case $arg in
--dns-search=*)
DNS_SEARCH_ARG=""
;;
*)
;;
esac;
for arg in $1 $2; do
case $arg in
[0-9]*)
if [ -z $CIDR ] ; then
validate_cidr $arg
CIDR=$arg
shift 1
fi
;;
-with-dns)
shift 1
DNS_ARG=$(docker inspect --format '--dns {{ .NetworkSettings.IPAddress }}'" --link $DNS_CONTAINER_NAME:$DNS_CONTAINER_NAME" $DNS_CONTAINER_NAME 2>/dev/null) || true
DNS_SEARCH_ARG="--dns-search=."
for arg in $@; do
case $arg in
--dns-search=*)
DNS_SEARCH_ARG=""
;;
*)
;;
esac;
done
;;
esac;
done
CONTAINER=$(docker run $DNS_ARG $DNS_SEARCH_ARG -d "$@" | tail -n 1)
with_container_netns $CONTAINER attach $CIDR >/dev/null
+7 -6
View File
@@ -8,15 +8,16 @@ the host's configured name server.
## Using weaveDNS
The weave script command `launch-dns` starts the DNS
container. Subsquently, giving any container a hostname in the domain
The weave script command `launch-dns` starts the DNS container, and
then you use the `--with-dns` option on containers you wish to use it.
Subsquently, giving any container a hostname in the domain
`.weave.local` will register it in DNS. For example:
```bash
$ weave launch
$ weave launch-dns 10.1.0.2/16
$ 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)
$ shell1=$(weave run --with-dns 10.1.1.26/24 -ti -h ubuntu.weave.local ubuntu)
$ docker attach $shell1
# ping pingme
@@ -39,13 +40,13 @@ 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
weave run --with-dns 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
supply it as the DNS server to the new container. Similarly, both
If you use the `--with-dns` option, `weave run` will automatically
supply the DNS server address to the new container. And both
`weave run` and `weave attach` will register the hostname of the given
container against the given weave network IP address.