Skip to content

Instantly share code, notes, and snippets.

@frankleng
Forked from dimitrovs/dockerhost.sh
Created July 20, 2016 23:41
Show Gist options
  • Save frankleng/1c651962d2b41f771a61187e4fa51fe9 to your computer and use it in GitHub Desktop.
Save frankleng/1c651962d2b41f771a61187e4fa51fe9 to your computer and use it in GitHub Desktop.
Add the IP of a dockerhost to the /etc/hosts file of a Docker container if not already there.
#!/bin/bash
if [[ -z $(grep dockerhost /etc/hosts) ]]
then
echo `/sbin/ip route|awk '/default/ { print $3 }'` dockerhost >> /etc/hosts
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment