Detect ip6tables failure without full ipv6 support

Error when running with kernel from Kata Containers:
    can't initialize ip6tables table `filter':
    Table does not exist (do you need to insmod?)
    Perhaps ip6tables or your kernel needs to be upgraded.

This happens also in Apple Containers. Fallback to ipv4 only.
The alternative is building a custom kernel, with full support.
This commit is contained in:
Anders F Björklund
2025-09-29 18:29:40 +02:00
parent f20102c99e
commit 9479b9cd56

View File

@@ -271,7 +271,10 @@ func isIPv6UnavailableError(err error) bool {
// even on hosts that lack ip6tables setup.
// Preferably users would either have ip6tables setup properly or else disable ipv6 in docker
const dockerIPV6TablesError = "Error response from daemon: Failed to Setup IP tables: Unable to enable NAT rule: (iptables failed: ip6tables"
return strings.HasPrefix(errorMessage, dockerIPV6DisabledError) || strings.HasPrefix(errorMessage, dockerIPV6TablesError)
// we get this error when ipv6 is missing in kernel
const dockerIPV6PolicyError = "Error response from daemon: setting default policy to DROP in FORWARD chain failed: (iptables failed: ip6tables"
return strings.HasPrefix(errorMessage, dockerIPV6DisabledError) || strings.HasPrefix(errorMessage, dockerIPV6TablesError) || strings.HasPrefix(errorMessage, dockerIPV6PolicyError)
}
func isPoolOverlapError(err error) bool {