会挽雕弓如满月,西北望,射天狼。|

园龄:粉丝:关注:

在docker中启用systemd

参考:Docker systemd进程管理器

以 amazn linux 2023 测试

# cat amazonlinux-systemd

docker run -tid -p 2222:22 --hostname amazonlinux-systemd --name amazonlinux-systemd \
  --entrypoint=/usr/lib/systemd/systemd \
  --env container=docker \
  --mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup \
  --mount type=bind,source=/sys/fs/fuse,target=/sys/fs/fuse \
  --mount type=tmpfs,destination=/tmp \
  --mount type=tmpfs,destination=/run \
  --mount type=tmpfs,destination=/run/lock \
  amazonlinux-systemd --log-level=info --unit=sysinit.target

测试成功。

如果不加那几个目录的mount,但是增加--privileged=true,测试结果是可以启动,但是关闭容器后重启会失败。

报错日志:

Failed to open libbpf, cgroup BPF features disabled: Operation not supported

增加了mount的启动日志中相关的部分如下:

Not running with unified cgroup hierarchy, disabling cgroup BPF features.

区别在于是否systemd是否需要cgroup BPF features,操作系统一般是没有安装这个模块的。

本文作者:武平宁

本文链接:https://www.cnblogs.com/dewan/p/17632100.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   武平宁  阅读(563)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起