Methods for working with docker services. This object is $service within a docker_client object.

Details

Below is reference documentation for all methods for version '1.29' of the docker API - other versions are available. This documentation is automatically generated from docker's API schema, and so inaccuracies may exist between it and stevedore's interface (especially references to JSON objects). Please report any documentation that might be improved at https://github.com/richfitz/stevedore/issues

Methods

service_create

Create a service. Similar to the cli command docker service create.

Usage:

  service_create(name = NULL, labels = NULL, image = NULL,
      container_spec_labels = NULL, command = NULL,
      args = NULL, hostname = NULL, env = NULL, dir = NULL,
      user = NULL, groups = NULL, tty = NULL,
      open_stdin = NULL, read_only = NULL, mounts = NULL,
      stop_signal = NULL, stop_grace_period = NULL,
      health_check = NULL, hosts = NULL, dns_config = NULL,
      secrets = NULL, resources = NULL, restart_policy = NULL,
      placement = NULL, force_update = NULL,
      task_spec_networks = NULL, log_driver = NULL,
      update_config = NULL, rollback_config = NULL,
      networks = NULL, endpoint_spec = NULL,
      registry_auth = NULL, stream = stdout(), replicas = NULL,
      global = FALSE, detach = FALSE, timeout = 60,
      time_wait_stable = 5, task_template = NULL,
      container_spec = NULL)

Arguments:

  • name: Name of the service.

  • labels: User-defined key/value metadata.

  • image: The image name to use for the container.

  • container_spec_labels: User-defined key/value data.

  • command: The command to be run in the image.

  • args: Arguments to the command.

  • hostname: The hostname to use for the container, as a valid RFC 1123 hostname.

  • env: A list of environment variables in the form VAR=value.

  • dir: The working directory for commands to run in.

  • user: The user inside the container.

  • groups: A list of additional groups that the container process will run as.

  • tty: Whether a pseudo-TTY should be allocated.

  • open_stdin: Open stdin

  • read_only: Mount the container's root filesystem as read only.

  • mounts: Specification for mounts to be added to containers created as part of the service.

  • stop_signal: Signal to stop the container.

  • stop_grace_period: Amount of time to wait for the container to terminate before forcefully killing it.

  • health_check: A test to perform to check that the container is healthy. Construct with $types$health_config()

  • hosts: A list of hostnames/IP mappings to add to the container's /etc/hosts file. The format of extra hosts on swarmkit is specified in: http://man7.org/linux/man-pages/man5/hosts.5.html IP_address canonical_hostname [aliases...]

  • dns_config: Specification for DNS related configurations in resolver configuration file (resolv.conf). Construct with $types$dns_config()

  • secrets: Secrets contains references to zero or more secrets that will be exposed to the service.

  • resources: Resource requirements which apply to each individual container created as part of the service. Construct with $types$task_resources()

  • restart_policy: Specification for the restart policy which applies to containers created as part of this service. Construct with $types$task_restart_policy()

  • placement: Construct with $types$task_placement()

  • force_update: A counter that triggers an update even if no relevant parameters have been changed.

  • task_spec_networks: NA

  • log_driver: Specifies the log driver to use for tasks created from this spec. If not present, the default one for the swarm will be used, finally falling back to the engine default if not specified.

  • update_config: Specification for the update strategy of the service.

  • rollback_config: Specification for the rollback strategy of the service.

  • networks: Array of network names or IDs to attach the service to.

  • endpoint_spec: Properties that can be configured to access and load balance a service.

  • registry_auth: A base64-encoded auth configuration for pulling from private registries. hrefhttps://docs.docker.com/engine/api/1.29/#section/AuthenticationSee the authentication section for details.

  • stream: The stream to send output to. Options here are (1) a connection object (e.g. stdout(), stderr() or a writable open file connection object, (2) a scalar character indicating a filename to write to, or (3) FALSE or NULL to disable any output.

  • replicas: Number of replicas to use. If NULL (the default) then a single replica is used (the same behaviour as the command line client).

  • global: Logical, indicating if this should be a "global" service (running one instance on each node) rather than a "replicated" service (running across nodes - the default).

  • detach: Logical, indicating if we should exit immediately, rather than waiting for the service to converge. This option is named for consistency with docker service create - this command never "attaches" in the sense of a single container.

  • timeout: Time, in seconds, to wait for the service to converge when detach = FALSE. If the service has not converged by this time an error will be thrown, but the docker daemon will continue trying to start the service.

  • time_wait_stable: Time, in seconds, to wait for the service to stay up after it has started. This is needed to detect services that fail shortly after starting. The default is 5 seconds, which matches the command line client.

  • task_template: User modifiable task configuration. Construct with $types$task_spec(). If this is given then 'container_spec', 'resources', 'restart_policy', 'placement', 'force_update', 'task_spec_networks' and 'log_driver' must all be NULL.

  • container_spec: Construct with $types$container_spec(). If this is given then 'image', 'container_spec_labels', 'command', 'args', 'hostname', 'env', 'dir', 'user', 'groups', 'tty', 'open_stdin', 'read_only', 'mounts', 'stop_signal', 'stop_grace_period', 'health_check', 'hosts', 'dns_config' and 'secrets' must all be NULL.

get

Get a service by name or id

Usage:

  get(id)

Arguments:

  • id: A scalar character with the network's name or id (abbreviations of the id are allowed and will be resolved by the docker daemon).

help

Display help for this object

Usage:

  help(help_type = getOption("help_type"))

Arguments:

  • help_type: Passed to utils::help, can be one of "text", "html" or "pdf" (or an abbreviation). By default it uses the value getOption("help_type") and should follow the same behaviour as other R help (e.g., using "?")

service_list

List services. Similar to the cli command docker service list.

Usage:

  service_list(filters = NULL)

Arguments:

  • filters: A named character vector of filters to process on the services list. Available filters:

    • id=<service id>

    • label=<service label>

    • mode=["replicated"|"global"]

    • name=<service name>

service_delete

Delete a service. Similar to the cli command docker service rm.

Usage:

  service_delete(id)

Arguments:

  • id: ID or name of service.

See also

docker_service for information on service objects.