if you need the host.docker.internal (for example, nginx proxy to your host network), use an entrypoint script (IE: ENTRYPOINT['/entrypoint.sh'])
" install iputils-ping & iproute2 (or like packages)
" check if the host name resolves,
" if not, then get the gateway of the current network (which is the host)
" and set it in the containers host file
!/bin/sh
HOST_DOMAIN="host.docker.internal"
ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
if [ $? -ne 0 ]; then
HOST_IP=$(ip route | awk 'NR==1 {print $3}')
echo -e "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
fi
Cheers ;-)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
if you need the host.docker.internal (for example, nginx proxy to your host network), use an entrypoint script (IE: ENTRYPOINT['/entrypoint.sh'])
" install iputils-ping & iproute2 (or like packages)
" check if the host name resolves,
" if not, then get the gateway of the current network (which is the host)
" and set it in the containers host file
!/bin/sh
HOST_DOMAIN="host.docker.internal"
ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
if [ $? -ne 0 ]; then
HOST_IP=$(ip route | awk 'NR==1 {print $3}')
echo -e "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
fi
Cheers ;-)