portfolio/docker/docker-entrypoint.sh

15 lines
483 B
Bash
Executable File

#!/bin/sh
# This entrypoint script is designed to populate "host.docker.internal" in /etc/hosts on startup until https://github.com/docker/for-linux/issues/264 is fixed and released.
HOST_DOMAIN="host.docker.internal"
grep $HOST_DOMAIN /etc/hosts && ping -q -c1 $HOST_DOMAIN
if [ $? -ne 0 ]; then
HOST_IP=$(ip route | awk 'NR==1 {print $3}')
echo "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
echo "Added $HOST_IP $HOST_DOMAIN to /etc/hosts"
fi
echo Running command "$@"
eval "$@"