dockerd: fix rootless detection (alternative to #39024)#39138
dockerd: fix rootless detection (alternative to #39024)#39138cpuguy83 merged 1 commit intomoby:masterfrom
Conversation
The `--rootless` flag had a couple of issues: * moby#38702: euid=0, $USER="root" but no access to cgroup ("rootful" Docker in rootless Docker) * moby#39009: euid=0 but $USER="docker" (rootful boot2docker) To fix moby#38702, XDG dirs are ignored as in rootful Docker, unless the dockerd is directly running under RootlessKit namespaces. RootlessKit detection is implemented by checking whether `$ROOTLESSKIT_STATE_DIR` is set. To fix moby#39009, the non-robust `$USER` check is now completely removed. The entire logic can be illustrated as follows: ``` withRootlessKit := getenv("ROOTLESSKIT_STATE_DIR") rootlessMode := withRootlessKit || cliFlag("--rootless") honorXDG := withRootlessKit useRootlessKitDockerProxy := withRootlessKit removeCgroupSpec := rootlessMode adjustOOMScoreAdj := rootlessMode ``` Close moby#39024 Fix moby#38702 moby#39009 Signed-off-by: Akihiro Suda <[email protected]>
|
@tonistiigi @tiborvass @cpuguy83 @tianon @thaJeztah I'd like to get this merged before DockerCon 🙏 |
Codecov Report
@@ Coverage Diff @@
## master #39138 +/- ##
==========================================
- Coverage 37.05% 37.05% -0.01%
==========================================
Files 612 612
Lines 45400 45411 +11
==========================================
+ Hits 16824 16826 +2
- Misses 26294 26302 +8
- Partials 2282 2283 +1 |
|
Not a functional change and only slightly different but can be edit: Basically, the difference is that |
|
That might be hard to implement, because |
|
@AkihiroSuda Ok, not that important. |
|
Rootful ("child") |
|
Yes, but make sure to create volume for |
|
Thanks @AkihiroSuda! We're now running the rootless container as follows: Note that With these changes, the only "suspicious" warning we still get on startup of rootful |
Signed-off-by: Akihiro Suda [email protected]
- What I did
Fix #38702 #39009
- How I did it
The
--rootlessflag had a couple of issues:To fix #38702, XDG dirs are ignored as in rootful Docker, unless the
dockerd is directly running under RootlessKit namespaces.
RootlessKit detection is implemented by checking whether
$ROOTLESSKIT_STATE_DIRis set.To fix #39009, the non-robust
$USERcheck is now completely removed.The entire logic can be illustrated as follows:
Close #39024
Fix #38702 #39009
- How to verify it
/var/run/docker.sockin the container, not on$XDG_RUNTIME_DIR/docker.sockin the container:$USERto non-"root" does not break rootful Docker- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
https://twitter.com/hashtag/WorldPenguinDay?f=image