Skip to content

Instantly share code, notes, and snippets.

@blackandred
Last active January 1, 2017 17:05
Show Gist options
  • Save blackandred/e72c8fdf7cf239896835387e969d096e to your computer and use it in GitHub Desktop.
Save blackandred/e72c8fdf7cf239896835387e969d096e to your computer and use it in GitHub Desktop.
Docker: Get host IP and add it locally as docker_host_machine so it could be accessible eg. via http://docker_host_machine
#!/bin/bash
#
# Get host IP and add it locally as docker_host_machine so it could be accessible eg. via http://docker_host_machine
# ================================
# Requirements: iproute2
#
cat /etc/hosts | grep -v "docker_host_machine" > /etc/hosts.2 && mv /etc/hosts.2 /etc/hosts
echo "$(ip route show|grep src|awk '{print $9}') docker_host_machine" >> /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment