Last active
August 29, 2015 14:23
-
-
Save maiha/6450c82672e4d2b02807 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function docker-port-mappings() { | |
local x="" | |
for x in $(docker ps -q); docker port $x | |
} | |
function docker-kafka-iptables() { | |
local hp="host port" | |
local gp="guest port" | |
for hp in 2181 9092; do | |
for gp in $(docker-port-mappings |grep $hp | head -1 | sed -r "s/.*:(.*)/\1/g"); do | |
echo iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport $hp -j REDIRECT --to-port $gp | |
done | |
done | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 2181 -j REDIRECT --to-port 32768 | |
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 9092 -j REDIRECT --to-port 32769 | |
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 9093 -j REDIRECT --to-port 32770 | |
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 9094 -j REDIRECT --to-port 32771 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment