class documentation

class Service(Model): (source)

View In Hierarchy

A service.

Method force_update Force update the service even if no changes require it.
Method logs Get log stream for the service. Note: This method works only for services with the ``json-file`` or ``journald`` logging drivers.
Method remove Stop and remove the service.
Method scale Scale service container.
Method tasks List the tasks in this service.
Method update Update a service's configuration. Similar to the ``docker service update`` command.
Class Variable id_attribute Undocumented
Property name The service's name.
Property version The version number of the service. If this is not the same as the server, the :py:meth:`update` function will not work and you will need to call :py:meth:`reload` before calling it again.

Inherited from Model:

Method __eq__ Undocumented
Method __hash__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method reload Load this object from the server again and update ``attrs`` with the new data.
Instance Variable attrs Undocumented
Instance Variable client Undocumented
Instance Variable collection Undocumented
Property id The ID of the object.
Property short_id The ID of the object, truncated to 12 characters.
def force_update(self): (source)

Force update the service even if no changes require it. Returns: bool: ``True`` if successful.

def logs(self, **kwargs): (source)

Get log stream for the service. Note: This method works only for services with the ``json-file`` or ``journald`` logging drivers. Args: details (bool): Show extra details provided to logs. Default: ``False`` follow (bool): Keep connection open to read logs as they are sent by the Engine. Default: ``False`` stdout (bool): Return logs from ``stdout``. Default: ``False`` stderr (bool): Return logs from ``stderr``. Default: ``False`` since (int): UNIX timestamp for the logs staring point. Default: 0 timestamps (bool): Add timestamps to every log line. tail (string or int): Number of log lines to be returned, counting from the current end of the logs. Specify an integer or ``'all'`` to output all log lines. Default: ``all`` Returns: generator: Logs for the service.

def remove(self): (source)

Stop and remove the service. Raises: :py:class:`docker.errors.APIError` If the server returns an error.

def scale(self, replicas): (source)

Scale service container. Args: replicas (int): The number of containers that should be running. Returns: bool: ``True`` if successful.

def tasks(self, filters=None): (source)

List the tasks in this service. Args: filters (dict): A map of filters to process on the tasks list. Valid filters: ``id``, ``name``, ``node``, ``label``, and ``desired-state``. Returns: :py:class:`list`: List of task dictionaries. Raises: :py:class:`docker.errors.APIError` If the server returns an error.

def update(self, **kwargs): (source)

Update a service's configuration. Similar to the ``docker service update`` command. Takes the same parameters as :py:meth:`~ServiceCollection.create`. Raises: :py:class:`docker.errors.APIError` If the server returns an error.

The service's name.

The version number of the service. If this is not the same as the server, the :py:meth:`update` function will not work and you will need to call :py:meth:`reload` before calling it again.