class Docker::API::Exec

This class represents the Docker API exec related endpoints. @see docs.docker.com/engine/api/v1.40/#tag/Exec

Public Instance Methods

create(name, body = {}) click to toggle source

Run a command inside a running container.

Docker API: POST /containers/{id}/exec @see docs.docker.com/engine/api/v1.40/#operation/ContainerExec

@param name [String]: The ID or name of the container. @param body [Hash]: Request body to be sent as json.

# 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) click to toggle source

Return low-level information about an exec instance.

Docker API: GET /exec/{id}/json @see docs.docker.com/engine/api/v1.40/#operation/ExecInspect

@param name [String]: Exec instance ID.

# File lib/docker/api/exec.rb, line 51
def details name
    @connection.get("/exec/#{name}/json")
end
resize(name, params = {}) click to toggle source

Resize the TTY session used by an exec instance.

Docker API: POST /exec/{id}/resize @see docs.docker.com/engine/api/v1.40/#operation/ExecResize

@param name [String]: Exec instance ID. @param body [Hash]: Request body to be sent as json.

# File lib/docker/api/exec.rb, line 40
def resize name, params = {}
    @connection.post(build_path("/exec/#{name}/resize", params))
end
start(name, body = {}) click to toggle source

Start a previously set up exec instance.

Docker API: POST /exec/{id}/start @see docs.docker.com/engine/api/v1.40/#operation/ExecStart

@param name [String]: Exec instance ID. @param body [Hash]: Request body to be sent as json. @param &block: Replace the default output to stdout behavior.

# 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