Repository navigation
OCI: make /run a tmpfs - #51950
OCI: make /run a tmpfs#51950thaJeztah wants to merge 1 commit into
/run a tmpfs#51950Conversation
Our defaults currently don't specify a mount for `/run`, which means that files inside that directory are persisted in the container's filesystem. This can be problematic in some cases, for example, after a forced shutdown of a container (`SIGKILL`), pid-files may be left behind (e.g. `/run/docker.pid` in a DIND container), preventing the docker daemon to be started. From the [FHS spec]: > This directory contains system information data describing the system > since it was booted. Files under this directory must be cleared (removed > or truncated as appropriate) at the beginning of the boot process. From the [systemd file hierarchy requirements]: > `/run` must exist as an empty mount point and will automatically be mounted > by systemd with a tmpfs. In moby, these defaults were added in 9c4570a, but copying the [existing defaults] before that. Comparing the defaults with containerd; containerd uses a tmpfs for `/run`. This mount was added in the [initial client] implementation; unortunately, there's no additional context in that commit describing it diverging from docker's defaults. This patch aligns the defaults with containerd and adds `/run` as a tmpfs, using the same options as [containerd's defaults]. With this patch: docker run --rm alpine sh -c 'mount | grep /run' tmpfs on /run type tmpfs (rw,nosuid,size=65536k,mode=755) [existing defaults]: https://github.com/moby/moby/blob/9c4570a958df42d1ad19364b1a8da55b891d850a/daemon/execdriver/native/template/default_template_linux.go#L46-L85 [FHS spec]: https://specifications.freedesktop.org/fhs/latest/run.html [systemd file hierarchy requirements]: https://github.com/systemd/systemd/blob/v259/docs/SYSTEMD_FILE_HIERARCHY_REQUIREMENTS.md#systemd-file-hierarchy-requirements [initial client]: containerd/containerd@d0e5732 [containerd's defaults]: https://github.com/containerd/containerd/blob/v2.2.1/pkg/oci/mounts.go#L63-L68 Signed-off-by: Sebastiaan van Stijn <[email protected]>
| { | ||
| Destination: "/run", | ||
| Type: "tmpfs", | ||
| Source: "tmpfs", | ||
| Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"}, | ||
| }, |
There was a problem hiding this comment.
FWIW; checking on a Ubuntu 24.04 droplet on DigitalOcean; mount options there are;
tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=98468k,mode=755,inode64)
There was a problem hiding this comment.
We could probably add nodev (perhaps in containerd as well). Perhaps if we want to harden things, we could add nr_inodes with some sensible limit (4k? 8k? 16k?); https://www.man7.org/linux/man-pages/man5/tmpfs.5.html
|
Some failures look related, but could be poorly written tests (or test plugin binary) assuming that |
|
Hm.. ok so this may be a fun one; looks like this (at least at a glance) is where things go wrong; this code; Line 80 in d5fd0c5 Creates a path on the host, but within the plugin's rootfs. For example, in the test that's failing, it creates; Or, if it would be a normal path ( This path is used for the plugin's fifo, which also gets created first; Line 89 in d5fd0c5 Line 98 in d5fd0c5 moby/daemon/logger/plugin_unix.go Lines 14 to 23 in d5fd0c5 Or: And this path is missing; time="2026-01-28T08:51:28.362724136Z" level=debug msg="error response for POST request" error-response="failed to create task for container: failed to initialize logging driver: error creating logger: open /run/docker/logging/21a71cb6d72506281fd26d9a0bc4f54348d2d159e1af1d3e0e7d54ec9c03289d: no such file or directory" method=POST module=api request-url=/v1.53/containers/8f1aa5e1f77ed16e21a19c7aabf1c80644711cc46e908463874547da4be2118f/start status=400 vars="map[name:8f1aa5e1f77ed16e21a19c7aabf1c80644711cc46e908463874547da4be2118f version:1.53]"
time="2026-01-28T08:51:29.262734428Z" level=debug msg="error response for POST request" error-response="failed to create task for container: failed to initialize logging driver: error creating logger: open /run/docker/logging/30776baccd64cc33f61aa8dbc20b221b49e76e50e3d198d761719ebc6d1295d8: no such file or directory" method=POST module=api request-url=/v1.53/containers/e96a8de27373598ea0331ec5c1c9fb9d5c7902b5f59e1dbf4cf21747399a0b1f/start status=400 vars="map[name:e96a8de27373598ea0331ec5c1c9fb9d5c7902b5f59e1dbf4cf21747399a0b1f version:1.53]"
time="2026-01-28T08:51:30.034454845Z" level=debug msg="error response for POST request" error-response="failed to create task for container: failed to initialize logging driver: error creating logger: open /run/docker/logging/88c9bd2922ea82e67cfbf93565d3e62c7aafd14ee8f9241b597a3c46bd557945: no such file or directory" method=POST module=api request-url=/v1.53/containers/022815ba1591db5df3cb1a2fe8f0cc9524903d91754e18b9e92ae1b00db12c8e/start status=400 vars="map[name:022815ba1591db5df3cb1a2fe8f0cc9524903d91754e18b9e92ae1b00db12c8e version:1.53]" |
|
Trying to summarize my thoughts from today's call in a succinct way (fingers crossed I'm successful): I'm very sympathetic to this change and would personally enjoy it. However, we've got 13 years of historical usage where the tmpfs does not exist, and we don't have either a way for users / image authors to "opt out" of this tmpfs, nor do we have a way for them to pre-create necessary directories (see #26528 for a concrete historical example where Red Hat apparently applied a patch similar to this and broke someone). While that's fine for new software (it could just be updated to pre-create the directory, after all), older software does not necessarily have that luxury. The best way to phrase my concerns about this change is that For example, it would be completely reasonable to have a full userspace that doesn't use or care about So in short, while I personally would enjoy this change, I'm officially a -1 on making it. 🖤 (perhaps instead we could work to add some way for image authors to specifically request that a given directory be a tmpfs? some kind of annotation or label or something similar to volumes, but useful instead of just annoying?) edit: thanks to Eric Curtin for helping find #8478 which is the ref I was really looking for when I found the one linked above |
Our defaults currently don't specify a mount for
/run, which means that files inside that directory are persisted in the container's filesystem. This can be problematic in some cases, for example, after a forced shutdown of a container (SIGKILL), pid-files may be left behind (e.g./run/docker.pidin a DIND container), preventing the docker daemon to be started.From the FHS spec:
From the systemd file hierarchy requirements:
In moby, these defaults were added in 9c4570a, but copying the existing defaults before that.
Comparing the defaults with containerd; containerd uses a tmpfs for
/run. This mount was added in the initial client implementation; unortunately, there's no additional context in that commit describing it diverging from docker's defaults.This patch aligns the defaults with containerd and adds
/runas a tmpfs, using the same options as containerd's defaults.With this patch:
- What I did
- How I did it
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)