Class: Docker::API::Task

Inherits:
Base
  • Object
show all
Defined in:
lib/docker/api/task.rb

Overview

This class represents the Docker API endpoints regarding tasks.

A task is a container running on a swarm. It is the atomic scheduling unit of swarm. Swarm mode must be enabled for these endpoints to work.

Instance Attribute Summary

Attributes inherited from Base

#api_version

Instance Method Summary collapse

Methods inherited from Base

#initialize, #request

Constructor Details

This class inherits a constructor from Docker::API::Base

Instance Method Details

#details(name) ⇒ Object

Inspect a task

Docker API: GET /tasks/id

Parameters:

  • name (String)

    : The ID or name of the task.

See Also:



23
24
25
# File 'lib/docker/api/task.rb', line 23

def details name
    get("/tasks/#{name}")
end

#list(params = {}) ⇒ Object

List tasks

Docker API: GET /tasks

Parameters:

  • params (Hash) (defaults to: {})

    : Parameters that are appended to the URL.

See Also:



13
14
15
# File 'lib/docker/api/task.rb', line 13

def list params = {}
    get("/tasks",params)
end

#logs(name, params = {}, &block) ⇒ Object

Get stdout and stderr logs from a task.

Docker API: GET /tasks/id/logs

Parameters:

  • name (String)

    : The ID or name of the task.

  • params (Hash) (defaults to: {})

    : Parameters that are appended to the URL.

  • &block:

    Replace the default output to stdout behavior.

See Also:



35
36
37
38
39
40
41
42
43
# File 'lib/docker/api/task.rb', line 35

def logs name, params = {}, &block
    path = "/tasks/#{name}/logs"

    if [true, 1 ].include? params[:follow]
        request(method: :get, path: path , params: params, response_block: block_given? ? block : default_streamer)
    else
        get(path, params)
    end
end