Skip to content

Commit

Permalink
Check docker can also resolve hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Apr 10, 2024
1 parent 774d00a commit e86f584
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions run_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ function check_hostname(){
printf "%b Hostname %s resolves to 127.0.0.1 but this is not supported\n" ${SKULL_EMOJI} "${1}"
return 1
fi
if ! docker_ip_address=$(docker run --rm alpine ping -c 1 "$1" | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -n 1); then
printf "%b ping command exited with a non-zero exit code from within docker\n" ${SKULL_EMOJI}
return 1
fi
if [[ "${ip_address}" != "${docker_ip_address}" ]]; then
printf "%b Hostname %s resolves to %s but within docker it resolves to %s\n" ${SKULL_EMOJI} "${1}" "${ip_address}" "${docker_ip_address}"
return 1
fi
}

function element_not_in_array() {
Expand Down

0 comments on commit e86f584

Please sign in to comment.