summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-11-08 15:32:10 -0800
committerJoffrey F <joffrey@docker.com>2018-11-28 11:56:28 -0800
commit9467fa480902d06e9f5a59d3c3b5770c8940e15c (patch)
tree58f6b96e3f917cdef3409f2d7db33bdda7f5bf43
parentf1d629fb5c3259c4e1b63cf3adf6ddf4f383153f (diff)
downloaddocker-py-9467fa480902d06e9f5a59d3c3b5770c8940e15c.tar.gz
Improve ulimits documentation
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/container.py2
-rw-r--r--docker/models/containers.py4
-rw-r--r--docker/types/containers.py17
-rw-r--r--docs/api.rst1
4 files changed, 21 insertions, 3 deletions
diff --git a/docker/api/container.py b/docker/api/container.py
index c59a6d0..6967a13 100644
--- a/docker/api/container.py
+++ b/docker/api/container.py
@@ -543,7 +543,7 @@ class ContainerApiMixin(object):
}
ulimits (:py:class:`list`): Ulimits to set inside the container,
- as a list of dicts.
+ as a list of :py:class:`docker.types.Ulimit` instances.
userns_mode (str): Sets the user namespace mode for the container
when user namespace remapping option is enabled. Supported
values are: ``host``
diff --git a/docker/models/containers.py b/docker/models/containers.py
index f60ba6e..98c7174 100644
--- a/docker/models/containers.py
+++ b/docker/models/containers.py
@@ -691,8 +691,8 @@ class ContainerCollection(Collection):
}
tty (bool): Allocate a pseudo-TTY.
- ulimits (:py:class:`list`): Ulimits to set inside the container, as
- a list of dicts.
+ ulimits (:py:class:`list`): Ulimits to set inside the container,
+ as a list of :py:class:`docker.types.Ulimit` instances.
user (str or int): Username or UID to run commands as inside the
container.
userns_mode (str): Sets the user namespace mode for the container
diff --git a/docker/types/containers.py b/docker/types/containers.py
index 9dfea8c..13eb4ef 100644
--- a/docker/types/containers.py
+++ b/docker/types/containers.py
@@ -58,6 +58,23 @@ class LogConfig(DictType):
class Ulimit(DictType):
+ """
+ Create a ulimit declaration to be used with
+ :py:meth:`~docker.api.container.ContainerApiMixin.create_host_config`.
+
+ Args:
+
+ name (str): Which ulimit will this apply to. A list of valid names can
+ be found `here <http://tinyurl.me/ZWRkM2Ztwlykf>`_.
+ soft (int): The soft limit for this ulimit. Optional.
+ hard (int): The hard limit for this ulimit. Optional.
+
+ Example:
+
+ nproc_limit = docker.types.Ulimit(name='nproc', soft=1024)
+ hc = client.create_host_config(ulimits=[nproc_limit])
+ container = client.create_container('busybox', 'true', host_config=hc)
+ """
def __init__(self, **kwargs):
name = kwargs.get('name', kwargs.get('Name'))
soft = kwargs.get('soft', kwargs.get('Soft'))
diff --git a/docs/api.rst b/docs/api.rst
index 6931245..2c2391a 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -151,4 +151,5 @@ Configuration types
.. autoclass:: SwarmExternalCA
.. autoclass:: SwarmSpec(*args, **kwargs)
.. autoclass:: TaskTemplate
+.. autoclass:: Ulimit
.. autoclass:: UpdateConfig