Created
August 11, 2015 20:52
-
-
Save Markbnj/779e8d4696c3f53b5ffb to your computer and use it in GitHub Desktop.
Inject the ec2 instance private IP into a docker container at start
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
# Sometimes you need to get the IP of the ec2 instance a container | |
# is running on. This script will get the IP from the local metadata | |
# service and inject it as an environment var. | |
localip=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) | |
export HOST_IP=$localip | |
sudo docker run -i -t -e "HOST_IP=$localip" --name="test" -h="test" some-repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment