Merge pull request #232 from zettio/revert-211-issue201_use_docker_bridge_ip

Revert "Use Docker bridge IP for DNS"
This commit is contained in:
Bryan Boreham committed 2014-11-24 18:02:53 +00:00
commit 5c76411e34
2 files changed
+11 -41

No files matched your search

+2 -10
View File
@@ -46,7 +46,6 @@ MTU=65535
PORT=6783 PORT=6783
HTTP_PORT=6784 HTTP_PORT=6784
DNS_HTTP_PORT=6785 DNS_HTTP_PORT=6785
DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0}
COMMAND=$1 COMMAND=$1
@@ -140,11 +139,6 @@ destroy_bridge() {
run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true
} }
docker_bridge_ip() {
DOCKER_BRIDGE_IP=$(ip -4 addr show $DOCKER_BRIDGE | grep -o 'inet [.0-9]*')
DOCKER_BRIDGE_IP=${DOCKER_BRIDGE_IP#inet }
}
# the following borrows from https://github.com/jpetazzo/pipework # the following borrows from https://github.com/jpetazzo/pipework
# run args $2 $3 ... as a command in the network namespace of container $1 # run args $2 $3 ... as a command in the network namespace of container $1
@@ -375,8 +369,7 @@ case "$COMMAND" in
shift 1 shift 1
check_not_running $DNS_CONTAINER_NAME $DNS_IMAGE check_not_running $DNS_CONTAINER_NAME $DNS_IMAGE
create_bridge create_bridge
docker_bridge_ip CONTAINER=$(docker run --privileged -d --name=$DNS_CONTAINER_NAME -v /var/run/docker.sock:/var/run/docker.sock $DNS_IMAGE "$@" | tail -n 1)
CONTAINER=$(docker run --privileged -d --name=$DNS_CONTAINER_NAME -p $DOCKER_BRIDGE_IP:53:53/udp -v /var/run/docker.sock:/var/run/docker.sock $DNS_IMAGE "$@" | tail -n 1)
with_container_netns $CONTAINER attach $CIDR >/dev/null with_container_netns $CONTAINER attach $CIDR >/dev/null
echo $CONTAINER echo $CONTAINER
;; ;;
@@ -414,8 +407,7 @@ case "$COMMAND" in
CIDR=$1 CIDR=$1
shift 1 shift 1
create_bridge create_bridge
docker_bridge_ip DNS_ARG=$(docker inspect --format '--dns {{ .NetworkSettings.IPAddress }}'" --link $DNS_CONTAINER_NAME:$DNS_CONTAINER_NAME" $DNS_CONTAINER_NAME 2>/dev/null) || true
DNS_ARG="--dns $DOCKER_BRIDGE_IP"
DNS_SEARCH_ARG="--dns-search=." DNS_SEARCH_ARG="--dns-search=."
for arg in $@; do for arg in $@; do
case $arg in case $arg in
+9 -31
View File
@@ -23,9 +23,9 @@ $ docker attach $shell1
... ...
``` ```
The weave IP address supplied to `weave launch-dns` must not be used The IP address supplied to `weave launch-dns` must not be used by any
by any other container, and the supplied network must contain all other container, and the supplied network must contain all application
application networks. networks.
## Domain search paths ## Domain search paths
@@ -50,46 +50,24 @@ supply it as the DNS server to the new container. Similarly, both
container against the given weave network IP address. container against the given weave network IP address.
In some circumstances, you may not want to use the `weave` In some circumstances, you may not want to use the `weave`
command. You can still take advantage of a running weaveDNS, with some command. You can still take advantage of a running weaveDNS, using the
extra manual steps. HTTP API.
### Using a different docker bridge
So that containers can connect to a stable and always routable IP
address, weaveDNS publishes its port 53 to the Docker bridge device,
which is assumed to be `docker0`.
Some configurations will use a different Docker bridge device. To
supply a different bridge device, use the environment variable
`DOCKER_BRIDGE`, e.g.,
```bash
$ sudo DOCKER_BRIDGE=someother weave launch-dns 10.0.1.2/16
```
### Supplying the DNS server ### Supplying the DNS server
If you want to start containers with `docker run` rather than `weave If you want to start containers with `docker run` rather than `weave
run`, you can supply the docker bridge IP as the `--dns` option to run`, you can supply the weaveDNS IP as the `--dns` option to make it
make it use weaveDNS: use weaveDNS:
```bash ```bash
$ docker_ip=$(docker inspect --format='{{ .NetworkSettings.Gateway }}' weavedns) $ dns_ip=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' weavedns)
$ shell2=$(docker run --dns=$docker_ip -ti ubuntu) $ shell2=$(docker run --dns=$dns_ip -ti ubuntu)
$ weave attach 10.1.1.27/24 $shell2 $ weave attach 10.1.1.27/24 $shell2
``` ```
This isn't very useful unless the container is also attached to the This isn't very useful unless the container is also attached to the
weave network (as in the last line above). weave network (as in the last line above).
Also note that this means of finding the Docker bridge's IP address
requires a running container (any one would do); another way to find
it is:
```bash
$ docker_ip=$(ip -4 addr show dev docker0 | grep -o 'inet [0-9.]*' | cut -d ' ' -f 2)
```
### Supplying the domain search path ### Supplying the domain search path
By default, Docker will provide containers with a `/etc/resolv.conf` By default, Docker will provide containers with a `/etc/resolv.conf`