#!/bin/bash set -e set -x base="$( cd "$(dirname "$0")" ; pwd -P )" id="$1" public_ip="$2" public_iface="$3" if [ -z "$public_iface" ]; then echo >&2 "usage: $0 ctid public_ip public_iface" exit 1 fi docker_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $id) if [ -n "$docker_ip" ]; then iptables -t nat -D PREROUTING -d $public_ip/32 -i $public_iface -j DNAT --to-destination $docker_ip || true fi exit 0