Modify weave run to use container name as fqdn
When run is invoked with `--with-dns` and a container name but no hostname, synthesise a fully qualified hostname from the container name and the weaveDNS domain and supply that as a hostname for the container.
This commit is contained in:
1 parent
678063efec
commit
108eea8b79
1 file changed
+14
-5
@@ -648,25 +648,34 @@ dns_args() {
|
|||||||
docker_bridge_ip
|
docker_bridge_ip
|
||||||
DNS_ARG="--dns $DOCKER_BRIDGE_IP"
|
DNS_ARG="--dns $DOCKER_BRIDGE_IP"
|
||||||
DNS_SEARCH_ARG="--dns-search=."
|
DNS_SEARCH_ARG="--dns-search=."
|
||||||
|
HOSTNAME_ARG=""
|
||||||
|
HOSTNAME_SPECIFIED=false
|
||||||
for arg in "$@" ; do
|
for arg in "$@" ; do
|
||||||
case $arg in
|
case $arg in
|
||||||
--dns-search=*)
|
--dns-search=*)
|
||||||
DNS_SEARCH_ARG=""
|
DNS_SEARCH_ARG=""
|
||||||
;;
|
;;
|
||||||
*)
|
--name=*)
|
||||||
|
HOSTNAME_ARG="--hostname=${arg#--name=}.$(dns_domain)"
|
||||||
|
;;
|
||||||
|
-h|--hostname=*)
|
||||||
|
HOSTNAME_SPECIFIED=true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
DNS_ARGS="$DNS_ARG $DNS_SEARCH_ARG"
|
if [ "$HOSTNAME_SPECIFIED" = "true" ] ; then
|
||||||
|
HOSTNAME_ARG=""
|
||||||
|
fi
|
||||||
|
DNS_ARGS="$DNS_ARG $DNS_SEARCH_ARG $HOSTNAME_ARG"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use the weaveDNS REST API to determine the local domain. If weaveDNS is not
|
# Use the weaveDNS REST API to determine the local domain. If weaveDNS is not
|
||||||
# running, return the default value ('weave.local.')
|
# running, return the default value ('weave.local')
|
||||||
dns_domain() {
|
dns_domain() {
|
||||||
if DOMAIN=$(http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT GET /domain 2>/dev/null) ; then
|
if DOMAIN=$(http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT GET /domain 2>/dev/null) ; then
|
||||||
echo $DOMAIN
|
echo ${DOMAIN%.}
|
||||||
else
|
else
|
||||||
echo 'weave.local.'
|
echo 'weave.local'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user