【问题标题】:How to enable non-docker actions to access docker-created files on my self hosted github actions runner? (rootless docker)如何在我的自托管 github 操作运行器上启用非 docker 操作来访问 docker 创建的文件? (无根码头工人)
【发布时间】:2021-05-14 04:07:25
【问题描述】:

Github 建议以非 root 用户身份运行他们的运行程序会引起一些 issues surrounding mixing docker and non-docker actions. 这很烦人,因为它导致结帐操作无法运行,因为它无法访问由运行的操作创建的文件码头集装箱。

可以通过使用无根 docker 运行操作运行程序来解决这个问题吗?

【问题讨论】:

    标签: docker github containers github-actions rootless


    【解决方案1】:

    这个问题可以通过以 root 运行 github actions runner 来解决,这在一定程度上降低了安全性。

    更好的解决方案是使用无根 docker:

    1. 如果您之前通过 Ubuntu 的默认存储库安装了 docker,请从系统中删除它。
    2. 从 Docker 的存储库安装 docker as directed here(我也推荐 启用 cgroupsV2,as described here) 并重新启动。这将为您提供下一步设置无根 docker 所需的 /usr/bin 中的脚本。
    3. 设置无根 docker as described here.
    4. 别忘了运行以下命令,这样 docker 在您注销后仍会继续运行(如指南中所述)
    systemctl --user enable docker
    systemctl --user start docker
    sudo loginctl enable-linger $(whoami)
    
    1. 还要确保创建无根上下文as described on that same page。这将使您自己的 docker 命令和 github 操作运行器自动使用无根 docker。

    2. 安装自托管运行器https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners(如果已安装则跳过)

    3. 重新(启动)动作运行器。这可以通过重新启动其 systemd 服务来完成。您的跑步者现在应该可以使用无根 docker

    如果您在使用 buildx 的新 docker build github 操作时遇到问题,另请参阅 How to solve error with rootless docker in github actions self hosted runner: write /proc/sys/net/ipv4/ping_group_range: invalid argument: unknown

    【讨论】:

    • 对于非 Fedora 系统来说,启用 cgroupsV2 还远未明确。因此,如果您想知道应该像我一样在 GRUB_CMDLINE_LINUX 中放入什么,您只需将文件编辑为 GRUB_CMDLINE_LINUX="systemd.unified_cgroup_hierarchy=1"
    猜你喜欢
    • 2023-03-27
    • 2021-02-04
    • 2022-08-13
    • 2021-10-03
    • 2022-11-21
    • 2021-12-01
    • 1970-01-01
    • 2021-05-14
    • 1970-01-01
    相关资源
    最近更新 更多