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