mirror of https://github.com/docker/docker-py.git
Improved LogConfig documentation
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
9467fa4809
commit
049e7e16d4
|
@ -476,13 +476,7 @@ class ContainerApiMixin(object):
|
||||||
isolation (str): Isolation technology to use. Default: `None`.
|
isolation (str): Isolation technology to use. Default: `None`.
|
||||||
links (dict or list of tuples): Either a dictionary mapping name
|
links (dict or list of tuples): Either a dictionary mapping name
|
||||||
to alias or as a list of ``(name, alias)`` tuples.
|
to alias or as a list of ``(name, alias)`` tuples.
|
||||||
log_config (dict): Logging configuration, as a dictionary with
|
log_config (LogConfig): Logging configuration
|
||||||
keys:
|
|
||||||
|
|
||||||
- ``type`` The logging driver name.
|
|
||||||
- ``config`` A dictionary of configuration for the logging
|
|
||||||
driver.
|
|
||||||
|
|
||||||
lxc_conf (dict): LXC config.
|
lxc_conf (dict): LXC config.
|
||||||
mem_limit (float or str): Memory limit. Accepts float values
|
mem_limit (float or str): Memory limit. Accepts float values
|
||||||
(which represent the memory limit of the created container in
|
(which represent the memory limit of the created container in
|
||||||
|
|
|
@ -576,13 +576,7 @@ class ContainerCollection(Collection):
|
||||||
``["label1", "label2"]``)
|
``["label1", "label2"]``)
|
||||||
links (dict or list of tuples): Either a dictionary mapping name
|
links (dict or list of tuples): Either a dictionary mapping name
|
||||||
to alias or as a list of ``(name, alias)`` tuples.
|
to alias or as a list of ``(name, alias)`` tuples.
|
||||||
log_config (dict): Logging configuration, as a dictionary with
|
log_config (LogConfig): Logging configuration.
|
||||||
keys:
|
|
||||||
|
|
||||||
- ``type`` The logging driver name.
|
|
||||||
- ``config`` A dictionary of configuration for the logging
|
|
||||||
driver.
|
|
||||||
|
|
||||||
mac_address (str): MAC address to assign to the container.
|
mac_address (str): MAC address to assign to the container.
|
||||||
mem_limit (int or str): Memory limit. Accepts float values
|
mem_limit (int or str): Memory limit. Accepts float values
|
||||||
(which represent the memory limit of the created container in
|
(which represent the memory limit of the created container in
|
||||||
|
|
|
@ -23,6 +23,36 @@ class LogConfigTypesEnum(object):
|
||||||
|
|
||||||
|
|
||||||
class LogConfig(DictType):
|
class LogConfig(DictType):
|
||||||
|
"""
|
||||||
|
Configure logging for a container, when provided as an argument to
|
||||||
|
:py:meth:`~docker.api.container.ContainerApiMixin.create_host_config`.
|
||||||
|
You may refer to the
|
||||||
|
`official logging driver documentation <https://docs.docker.com/config/containers/logging/configure/>`_
|
||||||
|
for more information.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
type (str): Indicate which log driver to use. A set of valid drivers
|
||||||
|
is provided as part of the :py:attr:`LogConfig.types`
|
||||||
|
enum. Other values may be accepted depending on the engine version
|
||||||
|
and available logging plugins.
|
||||||
|
config (dict): A driver-dependent configuration dictionary. Please
|
||||||
|
refer to the driver's documentation for a list of valid config
|
||||||
|
keys.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
>>> from docker.types import LogConfig
|
||||||
|
>>> lc = LogConfig(type=LogConfig.types.JSON, config={
|
||||||
|
... 'max-size': '1g',
|
||||||
|
... 'labels': 'production_status,geo'
|
||||||
|
... })
|
||||||
|
>>> hc = client.create_host_config(log_config=lc)
|
||||||
|
>>> container = client.create_container('busybox', 'true',
|
||||||
|
... host_config=hc)
|
||||||
|
>>> client.inspect_container(container)['HostConfig']['LogConfig']
|
||||||
|
{'Type': 'json-file', 'Config': {'labels': 'production_status,geo', 'max-size': '1g'}}
|
||||||
|
|
||||||
|
""" # flake8: noqa
|
||||||
types = LogConfigTypesEnum
|
types = LogConfigTypesEnum
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -50,9 +80,13 @@ class LogConfig(DictType):
|
||||||
return self['Config']
|
return self['Config']
|
||||||
|
|
||||||
def set_config_value(self, key, value):
|
def set_config_value(self, key, value):
|
||||||
|
""" Set a the value for ``key`` to ``value`` inside the ``config``
|
||||||
|
dict.
|
||||||
|
"""
|
||||||
self.config[key] = value
|
self.config[key] = value
|
||||||
|
|
||||||
def unset_config(self, key):
|
def unset_config(self, key):
|
||||||
|
""" Remove the ``key`` property from the ``config`` dict. """
|
||||||
if key in self.config:
|
if key in self.config:
|
||||||
del self.config[key]
|
del self.config[key]
|
||||||
|
|
||||||
|
@ -71,9 +105,14 @@ class Ulimit(DictType):
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
nproc_limit = docker.types.Ulimit(name='nproc', soft=1024)
|
>>> nproc_limit = docker.types.Ulimit(name='nproc', soft=1024)
|
||||||
hc = client.create_host_config(ulimits=[nproc_limit])
|
>>> hc = client.create_host_config(ulimits=[nproc_limit])
|
||||||
container = client.create_container('busybox', 'true', host_config=hc)
|
>>> container = client.create_container(
|
||||||
|
'busybox', 'true', host_config=hc
|
||||||
|
)
|
||||||
|
>>> client.inspect_container(container)['HostConfig']['Ulimits']
|
||||||
|
[{'Name': 'nproc', 'Hard': 0, 'Soft': 1024}]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
name = kwargs.get('name', kwargs.get('Name'))
|
name = kwargs.get('name', kwargs.get('Name'))
|
||||||
|
|
|
@ -140,6 +140,7 @@ Configuration types
|
||||||
.. autoclass:: Healthcheck
|
.. autoclass:: Healthcheck
|
||||||
.. autoclass:: IPAMConfig
|
.. autoclass:: IPAMConfig
|
||||||
.. autoclass:: IPAMPool
|
.. autoclass:: IPAMPool
|
||||||
|
.. autoclass:: LogConfig
|
||||||
.. autoclass:: Mount
|
.. autoclass:: Mount
|
||||||
.. autoclass:: Placement
|
.. autoclass:: Placement
|
||||||
.. autoclass:: Privileges
|
.. autoclass:: Privileges
|
||||||
|
|
Loading…
Reference in New Issue