nerdctl run -d 报"failed to call cni.Setup: plugin type=\"bridge\" failed (add) 问题处理

发布时间 2023-12-08 15:42:33作者: MhaiM

背景:执行 nerdctl  run -d  --name nginx -p8080:80 nginx 时,报如下错误

FATA[0000] failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2023-12-08T15:15:51+08:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): incompatible CNI versions; config is \"1.0.0\", plugin supports [\"0.1.0\" \"0.2.0\" \"0.3.0\" \"0.3.1\" \"0.4.0\"]"
Failed to write to log, write /var/lib/nerdctl/1935db59/containers/k8s.io/9e9c91a28fe6bf03d3c9c7e66701bdbadf718ddc11af094176983e3d292bf819/oci-hook.createRuntime.log: file already closed: unknown

1、分析原因:由于nerdctl 运行容器时,遇到了与 CNI(容器网络接口)插件版本不兼容的问题

2、解决方法:修改CNI bridge 配置的版本号

cat /etc/cni/net.d/nerdctl-bridge.conflist

"cniVersion": "1.0.0", 改为0.4.0 即可

3、再次执行nerdctl  run -d  --name nginx -p8080:80 nginx  验证