背景:执行 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、解决方法:

查看/etc/cni/net.d/10-calico.conflist CNI 的版本号"cniVersion": "0.4.0",

修改CNI bridge 配置的版本号

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

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

注:集群内nerdctl run 只能使用 容器ip+端口访问服务默认使用bridge网络模式的话,想要外部访问的话需要指定host 网络模式【host模式不用修改CNI version 版本】如下

nerdctl run -d  --name nginx --network host -p80:80 nginx 验证

 

posted on 2023-12-08 15:40  MhaiM  阅读(236)  评论(0编辑  收藏  举报