Skip to content

Instantly share code, notes, and snippets.

@stondo
Created April 18, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stondo/bb39d507ef4f02e3cdb44e2be76bc4fc to your computer and use it in GitHub Desktop.
Save stondo/bb39d507ef4f02e3cdb44e2be76bc4fc to your computer and use it in GitHub Desktop.
#!/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
@stondo
Copy link
Author

stondo commented Apr 18, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment