Skip to content

Commit 1f47197

Browse files
authored
Merge pull request #4824 from shouhei/fix/handle-missing-proc-net-tcp6-udp6
fix: cannot start container when IPv6 is disabled
2 parents 0a71ab7 + ebf70c5 commit 1f47197

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/portutil/port_allocate_linux.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
package portutil
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"net"
23+
"os"
2224

2325
"github.com/containerd/nerdctl/v2/pkg/portutil/iptable"
2426
"github.com/containerd/nerdctl/v2/pkg/portutil/procnet"
@@ -87,14 +89,14 @@ func getUsedPorts(ip string, protocol string) (map[uint64]bool, error) {
8789
// So we need some trick to process this situation.
8890
if protocol == "tcp" {
8991
tempTCPV6Data, err := procnet.ReadStatsFileData("tcp6")
90-
if err != nil {
92+
if err != nil && !errors.Is(err, os.ErrNotExist) {
9193
return nil, err
9294
}
9395
netprocItems = append(netprocItems, procnet.Parse(tempTCPV6Data)...)
9496
}
9597
if protocol == "udp" {
9698
tempUDPV6Data, err := procnet.ReadStatsFileData("udp6")
97-
if err != nil {
99+
if err != nil && !errors.Is(err, os.ErrNotExist) {
98100
return nil, err
99101
}
100102
netprocItems = append(netprocItems, procnet.Parse(tempUDPV6Data)...)

0 commit comments

Comments
 (0)