api.service

Module Contents

Classes

ServiceApiMixin()

Functions

_check_api_features(version,task_template,update_config,endpoint_spec)
_merge_task_template(current,override)
_check_api_features(version, task_template, update_config, endpoint_spec)
_merge_task_template(current, override)
class ServiceApiMixin
create_service(task_template, name=None, labels=None, mode=None, update_config=None, networks=None, endpoint_config=None, endpoint_spec=None)

Create a service.

Args:
task_template (TaskTemplate): Specification of the task to start as
part of the new service.

name (string): User-defined name for the service. Optional. labels (dict): A map of labels to associate with the service.

Optional.
mode (ServiceMode): Scheduling mode for the service (replicated
or global). Defaults to replicated.
update_config (UpdateConfig): Specification for the update strategy
of the service. Default: None
networks (list): List of network names or IDs to attach
the service to. Default: None.
endpoint_spec (EndpointSpec): Properties that can be configured to
access and load balance a service. Default: None.
Returns:
A dictionary containing an ID key for the newly created service.
Raises:
docker.errors.APIError
If the server returns an error.
inspect_service(service, insert_defaults=None)

Return information about a service.

Args:

service (str): Service name or ID. insert_defaults (boolean): If true, default values will be merged

into the service inspect output.
Returns:
True if successful.
Raises:
docker.errors.APIError
If the server returns an error.
inspect_task(task)

Retrieve information about a task.

Args:
task (str): Task ID
Returns:
(dict): Information about the task.
Raises:
docker.errors.APIError
If the server returns an error.
remove_service(service)

Stop and remove a service.

Args:
service (str): Service name or ID
Returns:
True if successful.
Raises:
docker.errors.APIError
If the server returns an error.
services(filters=None)

List services.

Args:
filters (dict): Filters to process on the nodes list. Valid
filters: id, name , label and mode. Default: None.
Returns:
A list of dictionaries containing data about each service.
Raises:
docker.errors.APIError
If the server returns an error.
service_logs(service, details=False, follow=False, stdout=False, stderr=False, since=0, timestamps=False, tail="all", is_tty=None)

Get log stream for a service. Note: This endpoint works only for services with the json-file or journald logging drivers.

Args:

service (str): ID or name of the service 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
is_tty (bool): Whether the service’s ContainerSpec
enables the TTY option. If omitted, the method will query the Engine for the information, causing an additional roundtrip.

Returns (generator): Logs for the service.

tasks(filters=None)

Retrieve a list of tasks.

Args:
filters (dict): A map of filters to process on the tasks list.
Valid filters: id, name, service, node, label and desired-state.
Returns:
(list): List of task dictionaries.
Raises:
docker.errors.APIError
If the server returns an error.
update_service(service, version, task_template=None, name=None, labels=None, mode=None, update_config=None, networks=None, endpoint_config=None, endpoint_spec=None, fetch_current_spec=False)

Update a service.

Args:
service (string): A service identifier (either its name or service
ID).
version (int): The version number of the service object being
updated. This is required to avoid conflicting writes.
task_template (TaskTemplate): Specification of the updated task to
start as part of the service.

name (string): New name for the service. Optional. labels (dict): A map of labels to associate with the service.

Optional.
mode (ServiceMode): Scheduling mode for the service (replicated
or global). Defaults to replicated.
update_config (UpdateConfig): Specification for the update strategy
of the service. Default: None.
networks (list): List of network names or IDs to attach
the service to. Default: None.
endpoint_spec (EndpointSpec): Properties that can be configured to
access and load balance a service. Default: None.
fetch_current_spec (boolean): Use the undefined settings from the
current specification of the service. Default: False
Returns:
True if successful.
Raises:
docker.errors.APIError
If the server returns an error.