Open dejangeci opened 5 years ago
also noticed (in separate project) that "host.docker.internal" does not work on Toolbox but on Desktop yep.
does sb have this issue resolved? / have it working on Toolbox?
I'm having exact same issue on Debian 9, outside of toolbox framework
I solved this issue by putting
extra_hosts:
host.docker.internal:10.0.2.2
I solved this issue by putting
extra_hosts: host.docker.internal:10.0.2.2
Thanks. Worked for me! How did you come up with this IP?
Resolví este problema poniendo
extra_hosts: host.docker.internal:10.0.2.2
Gracias. ¡Trabajó para mi! ¿Cómo se te ocurrió esta IP?
Where???
As I remember correctly, checked routing table after starting some dummy container then checked IPs one after each other empirically. That IP is mostly time constant, however intermittently I got corner case when that IP was different. As I am author of Gradle Environment Plugin helping working with Docker/Swarm I introduced heuristic method for resolving this IP:
https://github.com/Cognifide/gradle-environment-plugin/blob/master/src/main/kotlin/com/cognifide/gradle/environment/docker/runtime/Toolbox.kt#L15 https://github.com/Cognifide/gradle-environment-plugin/blob/master/src/main/kotlin/com/cognifide/gradle/environment/docker/runtime/Base.kt#L13 which could be a good explanation how I resolved it ;)
docker run alpine /bin/ash -c ip -4 route list match 0/0 | cut -d ' ' -f 3
workaround:
./entrypoint.sh
#!/bin/sh
set -e
#
function dig() {
nslookup host.docker.internal|grep Address:|grep -v 127.0.0|cut -d: -f2
}
HOST_IP=$(dig; while [ $? -ne 0 ]; do dig; done)
echo "$HOST_IP host.docker.internal" >> /etc/hosts
exec /bin/prometheus "$@"
compose.yml
user: root
entrypoint: /entrypoint.sh
volumes:
- ./entrypoint.sh:/entrypoint.sh
Issue: Prometheus container cannot scrape Docker host on which it's hosted.
Prometheus targets shows error:
Env: Windows 7 x64 Docker Toolbox on VirtualBox
Machine created with:
On Docker Desktop (Windows 10, HyperV) it works without issues.