Skip to content

Commit 34e0d56

Browse files
committed
Container interface: document exposing the host's os-release
In order to allow applications to detect the host OS version or other metadata, ask container managers to expose the os-release files as read-only bind mounts. For systemd-nspawn, we will also expose ID, BUILD_ID, VERSION_ID and VARIANT_ID as lowercase environment variables prefixed by the container_host_ string.
1 parent b3b1a08 commit 34e0d56

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

docs/CONTAINER_INTERFACE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ manager, please consider supporting the following interfaces.
121121
`container_ttys=pts/7 pts/8 pts/14` it will spawn three additional login
122122
gettys on ptys 7, 8, and 14.
123123

124+
4. To allow applications to detect the OS version and other metadata of the host
125+
running the container manager, if this is considered desirable, please parse
126+
the host's `/etc/os-release` and set a `$container_host_<key>=<VALUE>`
127+
environment variable for the ID fields described by the [os-release
128+
interface](https://www.freedesktop.org/software/systemd/man/os-release.html), eg:
129+
`$container_host_id=debian`
130+
`$container_host_build_id=2020-06-15`
131+
`$container_host_variant_id=server`
132+
`$container_host_version_id=10`
133+
124134
## Advanced Integration
125135

126136
1. Consider syncing `/etc/localtime` from the host file system into the

man/os-release.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@
339339
name in order to avoid name clashes. Applications
340340
reading this file must ignore unknown fields. Example:
341341
<literal>DEBIAN_BTS="debbugs://bugs.debian.org/"</literal></para>
342+
343+
<para>Container and sandbox runtime managers may make the host's
344+
identification data available to applications by providing the host's
345+
<filename>/etc/os-release</filename> and
346+
<filename>/usr/lib/os-release</filename> as respectively
347+
<filename>/run/host/etc/os-release</filename> and
348+
<filename>/run/host/usr/lib/os-release</filename>.</para>
342349
</refsect1>
343350

344351
<refsect1>

0 commit comments

Comments
 (0)