From 0593a6b372e0e0e712bd8eb83c751b8919dc3743 Mon Sep 17 00:00:00 2001 From: gdm85 Date: Sat, 7 Jun 2014 12:24:44 +0200 Subject: [PATCH] * conceal also docker host IP in docker-iptables * added docker-hosts for simplified hosts listing --- docker/scripts/docker-hosts | 21 +++++++++++++++++++++ docker/scripts/docker-iptables | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 docker/scripts/docker-hosts diff --git a/docker/scripts/docker-hosts b/docker/scripts/docker-hosts new file mode 100755 index 0000000..fa419d2 --- /dev/null +++ b/docker/scripts/docker-hosts @@ -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 diff --git a/docker/scripts/docker-iptables b/docker/scripts/docker-iptables index 9318a79..fe23c0a 100755 --- a/docker/scripts/docker-iptables +++ b/docker/scripts/docker-iptables @@ -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)