All Downloads are FREE. Search and download functionalities are using the official Maven repository.

testcontainers.host_ip.sh Maven / Gradle / Ivy

There is a newer version: 0.22.4
Show newest version
#!/bin/sh

set -eu

# Figuring out the IP of the docker host machine is a convoluted process. On Mac we pull that value from the special
# host.docker.internal hostname. Linux does not support that yet, so we have to use the routing table.
#
# See https://github.com/docker/for-linux/issues/264 to track host.docker.internal support on linux.
HOST_DOMAIN_IP="$(getent hosts host.docker.internal | awk '{ print $1 }')"

if [[ ! -z "${HOST_DOMAIN_IP}" ]]; then
    printf "${HOST_DOMAIN_IP}"
else
    printf "$(ip route | awk '/default/ { print $3 }')"
fi




© 2015 - 2024 Weber Informatics LLC | Privacy Policy