Skip to content

Commit 9467fa4

Browse files
committed
Improve ulimits documentation
Signed-off-by: Joffrey F <[email protected]>
1 parent f1d629f commit 9467fa4

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

docker/api/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def create_host_config(self, *args, **kwargs):
543543
}
544544
545545
ulimits (:py:class:`list`): Ulimits to set inside the container,
546-
as a list of dicts.
546+
as a list of :py:class:`docker.types.Ulimit` instances.
547547
userns_mode (str): Sets the user namespace mode for the container
548548
when user namespace remapping option is enabled. Supported
549549
values are: ``host``

docker/models/containers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ def run(self, image, command=None, stdout=True, stderr=False,
691691
}
692692
693693
tty (bool): Allocate a pseudo-TTY.
694-
ulimits (:py:class:`list`): Ulimits to set inside the container, as
695-
a list of dicts.
694+
ulimits (:py:class:`list`): Ulimits to set inside the container,
695+
as a list of :py:class:`docker.types.Ulimit` instances.
696696
user (str or int): Username or UID to run commands as inside the
697697
container.
698698
userns_mode (str): Sets the user namespace mode for the container

docker/types/containers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ def unset_config(self, key):
5858

5959

6060
class Ulimit(DictType):
61+
"""
62+
Create a ulimit declaration to be used with
63+
:py:meth:`~docker.api.container.ContainerApiMixin.create_host_config`.
64+
65+
Args:
66+
67+
name (str): Which ulimit will this apply to. A list of valid names can
68+
be found `here <http://tinyurl.me/ZWRkM2Ztwlykf>`_.
69+
soft (int): The soft limit for this ulimit. Optional.
70+
hard (int): The hard limit for this ulimit. Optional.
71+
72+
Example:
73+
74+
nproc_limit = docker.types.Ulimit(name='nproc', soft=1024)
75+
hc = client.create_host_config(ulimits=[nproc_limit])
76+
container = client.create_container('busybox', 'true', host_config=hc)
77+
"""
6178
def __init__(self, **kwargs):
6279
name = kwargs.get('name', kwargs.get('Name'))
6380
soft = kwargs.get('soft', kwargs.get('Soft'))

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,5 @@ Configuration types
151151
.. autoclass:: SwarmExternalCA
152152
.. autoclass:: SwarmSpec(*args, **kwargs)
153153
.. autoclass:: TaskTemplate
154+
.. autoclass:: Ulimit
154155
.. autoclass:: UpdateConfig

0 commit comments

Comments
 (0)