From 7286773837cb5366c5b7f8554cfa477ee6e2e8ac Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 4 Apr 2013 15:16:42 -0700 Subject: [PATCH] Continue cleaning up iptables rules from previous version, to avoid crashing after an upgrade Upstream-commit: ebc837957fb45c4ba4768a2344ea7b551bbb86e5 Component: engine --- components/engine/network.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/engine/network.go b/components/engine/network.go index 6576e5fa9a..9817bb84b3 100644 --- a/components/engine/network.go +++ b/components/engine/network.go @@ -100,6 +100,9 @@ func (mapper *PortMapper) cleanup() error { // Ignore errors - This could mean the chains were never set up iptables("-t", "nat", "-D", "PREROUTING", "-m", "addrtype", "--dst-type", "LOCAL", "-j", "DOCKER") iptables("-t", "nat", "-D", "OUTPUT", "-m", "addrtype", "--dst-type", "LOCAL", "-j", "DOCKER") + // Also cleanup rules created by older versions, or -X might fail. + iptables("-t", "nat", "-D", "PREROUTING", "-j", "DOCKER") + iptables("-t", "nat", "-D", "OUTPUT", "-j", "DOCKER") iptables("-t", "nat", "-F", "DOCKER") iptables("-t", "nat", "-X", "DOCKER") mapper.mapping = make(map[int]net.TCPAddr)