如何在 debian11 等新系统中 docker 容器内运行 systemctl

2022-02-17 15:05:31 +08:00
 euvkzx

在新的系统 debian11 或者 ubuntu21.10 都无法在容器内运行 systemctl, 报Failed to get d-bus connection: no such file or directory, 在 centos7 等旧系统是没这个问题的:
docker run -it -d --name trojan --net=host --restart=always --privileged jrohy/trojan init

试了下docker-systemctl-replacement 这个项目用来替换掉镜像内置的 systemctl 命令, 又会出现 no escaped character 报错(Jrohy/trojan(#610))。有没有遇到过类似情况的如何处理

1047 次点击
所在节点    Docker
2 条回复
euvkzx
2022-02-17 16:36:58 +08:00
可以了,用 https://github.com/gdraheim/docker-systemctl-replacement 这个项目就行,之前报的 no escaped character 错是因为 service 文件写得有问题才报的
julyclyde
2022-02-21 16:06:02 +08:00
首先,不要在容器里运行整套操作系统

其次,它需要 sys cap 权限

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/834524

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX