remove_public_route 460 B

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