euvkzx
V2EX  ›  Docker

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

  •  
  •   euvkzx · Feb 17, 2022 · 1832 views
    This topic created in 1572 days ago, the information mentioned may be changed or developed.

    在新的系统 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))。有没有遇到过类似情况的如何处理

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

    其次,它需要 sys cap 权限
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2932 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 62ms · UTC 15:10 · PVG 23:10 · LAX 08:10 · JFK 11:10
    ♥ Do have faith in what you're doing.