Linux Containers are AWESOME!!!
They’re almost as good as Solaris Zones/Containers…
Here’s a quick script to get the IP Addresses of all your running Linux Containers
#!/bin/bash
#
# Script to get the ip addresses of your running Linux Containers
#
#
# Get a list of Active Linux Containers
# Query for the ip addresses
export RUNTIME=`date +%m_%d_%y_%H%M`
export IPLOG=/tmp/lxc_ipaddr.${RUNTIME}.log
for i in `lxc-ls --active`
do
echo ${i} | tee >>${IPLOG}
echo "-----------" | tee >>${IPLOG}
sudo lxc-attach -n ${i} -- ifconfig eth0 | grep "inet addr:"| tee >>${IPLOG}
done
# Show the log file
cat ${IPLOG}
Leave a comment