Skip to content

Commit

Permalink
Merge pull request #619 from arnaudveron/add-docker-user-keyword
Browse files Browse the repository at this point in the history
Add user keyword to docker container resource
  • Loading branch information
arnaudveron committed Jun 8, 2023
2 parents bee354c + 2b53417 commit bc67768
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions opensvc/drivers/resource/container/docker/__init__.py
Expand Up @@ -106,6 +106,12 @@
"text": "Sets the :cmd:`docker run --net` argument. The default is ``none`` if :opt:`--net` is not specified in :kw:`run_args`, meaning the container will have a private netns other containers can share. A :c-res:`ip.netns` or :c-res:`ip.cni` resource can configure an ip address in this container. A container with ``netns=container#0`` will share the container#0 netns. In this case agent format a :opt:`--net=container:<name of container#0 docker instance>`. ``netns=host`` shares the host netns.",
"example": "container#0"
},
{
"keyword": "user",
"at": True,
"text": "Sets the :cmd:`docker run --user` argument.",
"example": "guest"
},
{
"keyword": "userns",
"at": True,
Expand Down Expand Up @@ -328,6 +334,7 @@ def __init__(self,
detach=True,
entrypoint=None,
rm=None,
user=None,
netns=None,
userns=None,
pidns=None,
Expand Down Expand Up @@ -361,6 +368,7 @@ def __init__(self,
self.detach = detach
self.entrypoint = entrypoint
self.rm = rm
self.user = user
self.netns = netns
self.userns = userns
self.pidns = pidns
Expand Down Expand Up @@ -841,6 +849,10 @@ def _add_run_args(self, errors="raise"):
if self.userns == "host":
args += ["--userns=host"]

if self.user is not None:
args = drop_option("--user", args, drop_value=True)
args += ["--user", self.user]

if self.privileged is not None:
args = drop_option("--privileged", args, drop_value=False)
if self.privileged:
Expand Down

0 comments on commit bc67768

Please sign in to comment.