-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If MG_DOCKER_HOST it is used, resolve hostname if needed to avoid chi…
…cken-and-egg problem
- Loading branch information
1 parent
e58f758
commit 89d6309
Showing
2 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
[[ "${MG_LOG_LEVEL}" == "DEBUG" ]] && set -x | ||
set -u | ||
|
||
if [[ "${MG_DOCKER_HOST:-x}" != "x" ]]; then | ||
set +e | ||
docker_host_name=$(echo "${MG_DOCKER_HOST}" | sed -r -e 's/^((tcp|tcps|http|https):\/\/)?([^\:]+)(:[[:digit:]]+)?$/\3/i') | ||
docker_host_ip=$(echo "${docker_host_name}" | xargs getent hosts) | ||
ret=$? | ||
set -e | ||
if [[ $ret -eq 0 ]]; then | ||
# host ip found | ||
docker_host_ip=$(echo "${docker_host_ip}" | cut -d ' ' -f 1) | ||
export MG_DOCKER_HOST=$(echo "${MG_DOCKER_HOST}" | sed -r -e "s/^((tcp|tcps|http|https):\/\/)?([^\:]+)(:[[:digit:]]+)?$/\1${docker_host_ip}\4/i") | ||
fi | ||
fi | ||
|
||
exec $@ |