Skip to content

Instantly share code, notes, and snippets.

@robin13 robin13/docker-ip
Created May 12, 2015

What would you like to do?
#!/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
Print out the ip addresses of currently running docker instances
=head1 AUTHOR
Robin Clarke C<>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.