From 80a01769cb1c4351c8007d9f8c60fa36fcf83485 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Fri, 15 Nov 2024 11:31:03 -0800 Subject: [PATCH] Enable UID GID persistence in podman --- src/rocker/extensions.py | 5 +++++ test/test_extension.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/rocker/extensions.py b/src/rocker/extensions.py index 3e22b71a..799b4e3e 100644 --- a/src/rocker/extensions.py +++ b/src/rocker/extensions.py @@ -300,6 +300,11 @@ class User(RockerExtension): def get_name(): return 'user' + def get_docker_args(self, cliargs): + if cliargs.get('use_podman', False): + return ' --userns=keep-id ' + return '' + def get_environment_subs(self): if not self._env_subs: user_vars = ['name', 'uid', 'gid', 'gecos','dir', 'shell'] diff --git a/test/test_extension.py b/test/test_extension.py index d264c35c..7779feef 100644 --- a/test/test_extension.py +++ b/test/test_extension.py @@ -419,6 +419,14 @@ def test_user_extension(self): snippet_result = p.get_snippet(user_override_active_cliargs) self.assertFalse('-s' in snippet_result) + user_podman_args = mock_cliargs + args_result = p.get_docker_args(user_podman_args) + self.assertNotIn('--userns=keep-id', args_result) + + user_podman_args['use_podman'] = True + args_result = p.get_docker_args(user_podman_args) + self.assertIn('--userns=keep-id', args_result) + @pytest.mark.docker def test_user_collisions(self): plugins = list_plugins()