Created
April 18, 2016 16:00
-
-
Save stondo/bb39d507ef4f02e3cdb44e2be76bc4fc to your computer and use it in GitHub Desktop.
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 | |
docker_container_name=$1 | |
if [[ -n "$docker_container_name" ]]; then | |
docker inspect $docker_container_name | grep '"IPAddress' | cut -d '"' -f4 | awk '{print $1}' | uniq | |
else | |
ifconfig docker0 | grep "inet addr" | cut -d: -f2 | awk '{print $1}' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Handy bash script to get the internal IP address of your docker containers by passing either CONTAINER_ID or NAME.
If no parameter is given, it will just output the IP of docker0 interface.