Skip to content

Instantly share code, notes, and snippets.

@junereycasuga
Forked from samundra/docker-network.sh
Created January 24, 2017 09:21
Show Gist options
  • Save junereycasuga/623aab7e36d1a0257c5e059ae0220566 to your computer and use it in GitHub Desktop.
Save junereycasuga/623aab7e36d1a0257c5e059ae0220566 to your computer and use it in GitHub Desktop.
List the actively running docker container ip
#!/bin/bash
set -e
## List the actively running docker container ip
## Usage chmod +x docker-network.sh
## ./docker-network.sh
##
## Output: container_1 - 172.17.0.2
## container-2 - 172.17.0.3
## container-2 - 172.17.0.4
## ...
DCONTAINERS=`docker ps --format='{{.Names}}'`
for d in ${DCONTAINERS[@]}; do
echo ${d} - `docker inspect ${d}| grep "IPAddress\": \"[0-9].*\""|\
sed 's/,//g' - | \cut -f2 -d ":" | sed 's/\"//g'` | sort -n
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment