diff --git a/libnetwork/cni/run_freebsd.go b/libnetwork/cni/run_freebsd.go index c356a864a..cca00aa83 100644 --- a/libnetwork/cni/run_freebsd.go +++ b/libnetwork/cni/run_freebsd.go @@ -8,6 +8,12 @@ import ( // add the default address. Note: this will also add ::1 as a side // effect. func setupLoopback(namespacePath string) error { - // The jexec wrapper runs the ifconfig command inside the jail. + // Try to run the command using ifconfig's -j flag (supported in 13.3 and later) + if err := exec.Command("ifconfig", "-j", namespacePath, "lo0", "inet", "127.0.0.1").Run(); err == nil { + return nil + } + + // Fall back to using the jexec wrapper to run the ifconfig command + // inside the jail. return exec.Command("jexec", namespacePath, "ifconfig", "lo0", "inet", "127.0.0.1").Run() }