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 Method Summary collapse

Methods inherited from Base

#initialize

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
    @connection.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 = {}
    @connection.get(build_path("/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 = build_path("/tasks/#{name}/logs", params)

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