Relaxed checking of userns_mode

When using docker-compose in combination with rootless podman
containers it is desirable to use the keep-id user namespace mapping.
By lifting the restriction to 'host' the userns_mode config can now be
used with podman to supply the keep-id or more complex configurations.

Signed-off-by: Jonathan Hettwer (bauen1) <j2468h@gmail.com>
This commit is contained in:
Jonathan Hettwer (bauen1) 2024-02-29 20:16:10 +01:00 committed by bauen1
parent bd164f928a
commit 2cebb82f68
1 changed files with 7 additions and 2 deletions

View File

@ -544,8 +544,13 @@ class HostConfig(dict):
if version_lt(version, '1.23'): if version_lt(version, '1.23'):
raise host_config_version_error('userns_mode', '1.23') raise host_config_version_error('userns_mode', '1.23')
if userns_mode != "host": # Do not check that userns_mode has a specific value, i.e. 'host'
raise host_config_value_error("userns_mode", userns_mode) # since more complex values might be supported by the daemon exposing
# the docker api, e.g. podman also supports 'keep-id'
if not isinstance(userns_mode, str):
raise host_config_type_error('userns_mode', userns_mode, 'string')
self['UsernsMode'] = userns_mode self['UsernsMode'] = userns_mode
if uts_mode: if uts_mode: