Last active
August 29, 2015 14:07
-
-
Save ngtuna/e42cef49c4d9b07d8af1 to your computer and use it in GitHub Desktop.
docker ps continuously
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| while [ 2 -gt 1 ] | |
| do | |
| declare -a containerID | |
| # Load file into array. | |
| ~/cf-docker/cf-docker/bin/docker -H 172.17.42.1:5555 ps | awk '{print $1}' > abc.txt | |
| let i=0 | |
| while IFS=$'\n' read -r line_data; do | |
| containerID[i]="${line_data}" | |
| ((++i)) | |
| done < abc.txt | |
| # Explicitly report array content. | |
| let i=1 | |
| echo > /usr/share/nginx/html/index.html | |
| while (( ${#containerID[@]} > i )); do | |
| echo "CONTAINER $i:" >> /usr/share/nginx/html/index.html | |
| conID=${containerID[i++]} | |
| echo "ID: $conID" >> /usr/share/nginx/html/index.html | |
| echo $(~/cf-docker/cf-docker/bin/docker -H 172.17.42.1:5555 inspect $conID | grep IPAddress) >> /usr/share/nginx/html/index.html | |
| echo "<br>" >> /usr/share/nginx/html/index.html | |
| done | |
| unset containerID | |
| sleep 5 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment