Class: Docker::API::Exec

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

Overview

This class represents the Docker API exec related endpoints.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#create(name, body = {}) ⇒ Object

Run a command inside a running container.

Docker API: POST /containers/id/exec

Parameters:

  • name (String)

    : The ID or name of the container.

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

    : Request body to be sent as json.

See Also:



14
15
16
# File 'lib/docker/api/exec.rb', line 14

def create name, body = {}
    @connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
end

#details(name) ⇒ Object

Return low-level information about an exec instance.

Docker API: GET /exec/id/json

Parameters:

  • name (String)

    : Exec instance ID.

See Also:



51
52
53
# File 'lib/docker/api/exec.rb', line 51

def details name
    @connection.get("/exec/#{name}/json")
end

#resize(name, params = {}) ⇒ Object

Resize the TTY session used by an exec instance.

Docker API: POST /exec/id/resize

Parameters:

  • name (String)

    : Exec instance ID.

  • body (Hash)

    : Request body to be sent as json.

See Also:



40
41
42
# File 'lib/docker/api/exec.rb', line 40

def resize name, params = {}
    @connection.post(build_path("/exec/#{name}/resize", params))
end

#start(name, body = {}, &block) ⇒ Object

Start a previously set up exec instance.

Docker API: POST /exec/id/start

Parameters:

  • name (String)

    : Exec instance ID.

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

    : Request body to be sent as json.

  • &block:

    Replace the default output to stdout behavior.

See Also:



27
28
29
30
# File 'lib/docker/api/exec.rb', line 27

def start name, body = {}, &block
    @connection.request(method: :post, path: "/exec/#{name}/start", headers: {"Content-Type": "application/json"},  body: body.to_json, 
        response_block: block_given? ? block : default_streamer )
end