瀏覽代碼

Continue cleaning up iptables rules from previous version, to avoid crashing after an upgrade

Solomon Hykes 12 年之前
父節點
當前提交
ebc837957f
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      network.go

+ 3 - 0
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)