1
0
mirror of https://github.com/juliengk/csf-post-docker.git synced 2023-10-10 13:37:41 +02:00

Add verification of NetworkMode setting when getting IP address value

This commit is contained in:
Julien Kassar 2016-09-26 08:58:27 -04:00
parent 7c303d7c3c
commit e78db14fbf

View File

@ -38,7 +38,13 @@ if [ `echo ${containers} | wc -c` -gt "1" ] ; then
rules=`docker port ${container} | sed 's/ //g'`
if [ `echo ${rules} | wc -c` -gt "1" ] ; then
netmode=`docker inspect -f "{{.HostConfig.NetworkMode}}" ${container}`
if [ $netmode == "default" ]; then
ipaddr=`docker inspect -f "{{.NetworkSettings.IPAddress}}" ${container}`
else
ipaddr=`docker inspect -f "{{.NetworkSettings.Networks.${netmode}.IPAddress}}" ${container}`
fi
for rule in ${rules} ; do
src=`echo ${rule} | awk -F'->' '{ print $2 }'`