Create a gist now

Instantly share code, notes, and snippets.

@stondo /dip.sh
Created Apr 18, 2016

What would you like to do?
#!/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
Owner
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