Skip to content

Instantly share code, notes, and snippets.

@hsm207
Created March 8, 2020 14:04
Show Gist options
  • Save hsm207/5bdee8c2c569d8df6c6d63a16dfc8a34 to your computer and use it in GitHub Desktop.
Save hsm207/5bdee8c2c569d8df6c6d63a16dfc8a34 to your computer and use it in GitHub Desktop.
Command to find the host's ip address from inside a container
# Thanks to: https://forums.docker.com/t/accessing-host-machine-from-within-docker-container/14248/10
docker run --network host \
--rm \
openjdk:8 bash -c "apt update; apt install net-tools; route | awk '/^default/ { print \$2 }' | grep -v 0.0.0.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment