Printing Docker Container IP Address

Just wanted to share a smarcut to print a docker container IP address.

Add the following to your ~/.bashrc or ~/.bash_profile

docker-ip() {
  docker inspect --format '{{ .NetworkSettings.IPAddress }}' "[email protected]"
}

After sourcing the file you can type on your sell docker-ip myContainerName and get back the IP address associated with the container:

$ docker-ip dnsdock
172.17.0.2

Got the idea from a post on this stackoverflow thread.