Created
May 12, 2015 07:56
-
-
Save robin13/14e9340f559e698e36bb to your computer and use it in GitHub Desktop.
docker-ip
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $ps = `docker ps`; | |
my @lines = split( /\n/, $ps ); | |
# Remove headers | |
shift( @lines ); | |
my $format = "%-15s %-12s %s\n"; | |
printf $format, 'IP', 'id', 'image'; | |
foreach my $line( @lines ){ | |
my( $id, $image ) = ( $line =~ m/^(.*?)\s+(.*?)\s+.*$/ ); | |
my $address = `docker inspect --format '{{ .NetworkSettings.IPAddress }}' $id`; | |
chomp( $address ); | |
printf $format, $address, $id, $image; | |
} | |
exit( 0 ); | |
=head1 NAME | |
docker-ip | |
=head1 SYNOPSIS | |
Print out the ip addresses of currently running docker instances | |
=head1 AUTHOR | |
Robin Clarke C<robin@robinclarke.net> | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment