wsl2 podman run 启动容器错误

wsl2中安装podman,启动容器报错

包含3个错误:

OCI runtime error: systemd is not available,unable to write pod event, CNI network "podman" not found

具体如下:

podman run --rm -it docker.io/alpine ash
ERRO[0000] unable to write pod event: "write unixgram @00039->/run/systemd/journal/socket: sendmsg: no such file or directory"
ERRO[0000] CNI network "podman" not found
Error: error configuring network namespace for container 686aa0ac15508ae265fee439f61e2fdb960ef5a7fb61d51a7818fbf78796261a: CNI network "podman" not found
Error: OCI runtime error: systemd cgroup flag passed, but systemd support for managing cgroups is not available

解决办法

添加参数:--cgroup-manager=cgroupfs, --events-backend=file ,--net=host

例子:

podman --cgroup-manager=cgroupfs --events-backend=file run --net=host --rm -it docker.io/alpine ash

也可以设置containers.conf
vi /etc/containers/containers.conf

[engine]
events_logger="file"
cgroup_manager="cgroupfs"

启动时就可以少加--cgroup-manager=cgroupfs--events-backend=file`这两个参数

参考: https://github.com/containers/podman/issues/4325

原文地址:https://www.cnblogs.com/iois/p/14673722.html