* conceal also docker host IP in docker-iptables

* added docker-hosts for simplified hosts listing
This commit is contained in:
gdm85 2014-06-07 12:24:44 +02:00
parent 05ee260412
commit 0593a6b372
2 changed files with 22 additions and 1 deletions

21
docker/scripts/docker-hosts Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
## docker-hosts
##
## @author gdm85
## script to show docker containers and their hostnames/IPv4
#
function enumerate_container_ips() {
local CID
for CID in $(docker ps -q -a); do
local NAME=$(docker inspect --format '{{ .Name }}' $CID | awk '{ print substr($0, 2, length($0)-1) }')
local HPATH=$(docker inspect --format '{{ .HostnamePath }}' $CID)
local IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID)
local HOSTNAME=$(<$HPATH)
echo -e "$NAME\t$HOSTNAME\t$IP"
done
}
enumerate_container_ips

View File

@ -10,7 +10,7 @@
function replace_iptables() {
local CID
local SEDCMD=""
local SEDCMD="-e s!172.17.42.1/32!dockerHost!g
for CID in $(docker ps -q -a); do
local NAME=$(docker inspect --format '{{ .Name }}' $CID | awk '{ print substr($0, 2, length($0)-1) }')
local IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID)