@@ -35,6 +35,14 @@ def container(
3535 start : bool = True ,
3636 restart_policy : str | None = None ,
3737 auto_remove : bool = False ,
38+ mounts : list [str ] | None = None ,
39+ privileged : bool = False ,
40+ hostname : str | None = None ,
41+ entrypoint : str | None = None ,
42+ user : str | None = None ,
43+ cpus : float | None = None ,
44+ memory : str | None = None ,
45+ extra_args : list [str ] | None = None ,
3846 dns : list [str ] | None = None ,
3947):
4048 """
@@ -54,6 +62,14 @@ def container(
5462 + start: start or stop the container
5563 + restart_policy: restart policy to apply when a container exits
5664 + auto_remove: automatically remove the container and its associated anonymous volumes when it exits
65+ + mounts: list of ``--mount`` specifications (e.g. ``type=bind,source=/src,target=/app``)
66+ + privileged: give extended privileges to the container
67+ + hostname: container hostname
68+ + entrypoint: override the default entrypoint
69+ + user: username or UID to run as
70+ + cpus: number of CPUs (e.g. ``1.5``)
71+ + memory: memory limit (e.g. ``512m``, ``1g``)
72+ + extra_args: list of additional raw arguments passed to ``docker container create``
5773 + dns: list of dns servers to be used by the container
5874
5975 **Examples:**
@@ -76,6 +92,21 @@ def container(
7692 auto_remove=True,
7793 )
7894
95+ # Run a container with mounts and resource limits
96+ docker.container(
97+ name="Deploy app container",
98+ container="myapp",
99+ image="myapp:latest",
100+ mounts=["type=bind,source=/host/data,target=/app/data"],
101+ privileged=True,
102+ hostname="myapp-host",
103+ entrypoint="/bin/sh",
104+ user="1000:1000",
105+ cpus=2.0,
106+ memory="512m",
107+ extra_args=["--cap-add", "NET_ADMIN"],
108+ )
109+
79110 # Stop a container
80111 docker.container(
81112 name="Stop Nginx container",
@@ -102,6 +133,14 @@ def container(
102133 pull_always ,
103134 restart_policy ,
104135 auto_remove ,
136+ mounts or list (),
137+ privileged ,
138+ hostname ,
139+ entrypoint ,
140+ user ,
141+ cpus ,
142+ memory ,
143+ extra_args or list (),
105144 dns or list (),
106145 )
107146 existent_container = host .get_fact (DockerContainer , object_id = container )
0 commit comments