-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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