Skip to content

Explain rootless limitations and why it's not possible for now #5763

Closed

Description

@TomChv

What is the issue?

Currently, Dagger runs using a Buildkit daemon with root privileged through --privileged option.
It's been more than a year that the subject of Dagger rootless in on the pipe and I would like to use this issue to gather all information we got so far and suggest a solution so we can close the debat for now.

Privileges

The advantage of running rootless is that you run the engine as a non-root user, meaning
that you mitigate potential vulnerabilities in the runtime. However, this means you
can hit Kernel level limitations such as ports exposition, networks, volumes and anything
basically protected by the Kernel.

Why it's important for some users to run as rootless?

As explained in #1287, some CI environment cannot allow root container, for security purpose or simple restriction.
For example, an uncontrolled environment that restrict the usage of privileges container.

Basically, without rootless some users may not be able to integrate Dagger to their CI.

Limitations

TL;DR Rootless could work but the limitations and tradeoffs involved are not worth it and will lead to a painful path.

Network

It is known as an actual limitation of rootless Buildkit:

Network mode is set to network.host by default

Since we implement internal network, we can use slirp but it really decrease performance compared to root.

See network speed comparison.

Distribution

Dagger aims to work on Windows, Mac and Linux no matter the distribution, however running Buildkit without privileges seems to limit the distribution to Ubuntu.

Using Ubuntu kernel is recommended.

Which lead to the question, what can we do for MacOS and Windows users?

Also, as explained by Erik

Which snapshotter will be usable inside the rootless containers involves an insane matrix of kernel version, configuration, fuse availability, upstream kernel patches used by certain distros, etc.
Any users that end up not being able to use the default overlayfs snapshotter will most likely experience noticeable slowdowns (with either the fuse-overlayfs implementation or especially the native copy-based one).

Volumes

Dagger relies on overlayfs which has limitation with a rootless daemon. Otherwise, runner execution might become extremely slow.

Using the overlayfs snapshotter requires kernel >= 5.11 or Ubuntu kernel. On kernel >= 4.18, the fuse-overlayfs snapshotter is used instead of overlayfs. On kernel < 4.18, the native snapshotter is used.

The constraint of version for overlayfs might create unstable behaviour and lack of performances on Dagger side.

Also it seems Rootlesskit supports multiple strategy

I dug into LWM mount doc and I think this actually supports all kind of mount we support in our API (with some limits though)

The propagation can be also set to rshared, but known not to work with --copy-up.

Note that rslave and rshared do not work as expected when the host root filesystem isn't mounted with "shared". (Use findmnt -n -l -o propagation / to inspect the current mount flag.)

Do these limitations are issues for Dagger? I think yes, but I would prefer having your opinion @vito @sipsma

An user tried on February to run Dagger using rootless Docker, but it hanged on host import/export operation.

GPU implementation

Not possible for now without --privileged

💡 See @sispma's comment on GPU.

The more annoying part of this is that the dagger engine is itself a docker container by default, isolated from the host.
It should already have access to the device files of the host since it runs w/ --privileged, but it will also need access to the rest of the possible files.

It seems that work around are possible but it can indeed lead to unstable behaviour.

Work around

You can run your own OCI container runtime following that guide however, if Dagger engine isn't run with privileged access, we cannot guarantee that you will access to the following feature:

  • Host interaction: read/write might fails or actually have some limitations.
  • Internal network and services: it will most likely fails since network will be on host by default or become really slow if you use slirp.
  • GPU: It's still experimental but this cannot work for now without maximum privileges.

The generic solution used by rootless buildkit is Rootlesskit but that has performance penalties.

Questions ?

  • What about rootless with --privileged? Is that a safer option, documentation says that it's almost safe. Is it technically possible?@sipsma
  • Do you disagree that Dagger network cannot be handled without --privileged? @vito
  • Do you disagree that Dagger cannot implement GPU without --privileged? @sipsma
  • Do the rootless container can impact our shim? I'm scared of this side effect.

The purpose of these questions is to acknowledge that for now, running without --privileged is not possible and will limit Dagger capabilities.
Indeed, if some user are ready to lose some capabilities, we might consider implementing a rootless option but at which cost?

Source

Next steps

As discussed with @gerhard, I'll open a PR that explain why Dagger should not be ran as rootless.
I wanted to first gather your opinions, that's why I started with that issue, then I'll include all your answers to the future doc.

WDYT? @vito @sipsma @dubo-dubon-duponey

Activity

  1. added
    area/documentation
    on Sep 5, 2023
  2. self-assigned this
    on Sep 5, 2023
  3. modified the milestone: v0.? on Sep 12, 2023
  4. mircubed commented on Sep 12, 2023

    @mircubed
    Contributor

    @TomChv would love to have you do a community call summary about this when it is ready

  5. TomChv commented on Sep 13, 2023

    @TomChv
    MemberAuthor

    @TomChv would love to have you do a community call summary about this when it is ready

    You want me to present it next week? I can prepare few slides and explain the problem so people can give their opinion

  6. gerhard commented on Sep 18, 2023

    @gerhard
    Contributor
  7. added a commit that references this issue on Sep 21, 2023
    748e4fb
  8. TomChv commented on Sep 21, 2023

    @TomChv
    MemberAuthor

    I opened a PR #5809 to continue the discussion on a more concret step, let's continue the discussion on it to merge it when it's ready :D

  9. added a commit that references this issue on Oct 12, 2023
    e63200d
  10. added 5 commits that reference this issue on Nov 24, 2023
    883f2e8
    ea66183
    50063d8
    3c7b16f
    86e2b6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions