#Add this shell script in your ~/.bashrc or relevant file:
nano ~/.bashrc
docker-ip() {
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"
}
#Then, to get an IP address of a container, simply do this:
docker-ip YOUR_CONTAINER_ID
#For the new version of the Docker, please use the following:
docker-ip() {
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$@"
}