Method: Docker::Exec#start!

Defined in:
lib/docker/exec.rb

#start!(options = {}, &block) ⇒ Array, Int

Start the Exec instance. The Exec instance is deleted after this so this command can only be run once.

Options Hash (options):

  • :stdin (Object) — default: nil

    The object to pass to STDIN.

  • :detach (TrueClass, FalseClass) — default: false

    Whether to attach to STDOUT/STDERR.

  • :tty (TrueClass, FalseClass) — default: false

    Whether to attach using a pseudo-TTY.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/docker/exec.rb', line 52

def start!(options = {}, &block)

  # Parse the Options
  tty = !!options.delete(:tty)
  detached = !!options.delete(:detach)
  stdin = options[:stdin]
  read_timeout = options[:wait]

  # Create API Request Body
  body = MultiJson.dump(
    'Tty' => tty,
    'Detach' => detached
  )
  excon_params = { body: body }

  msgs = Docker::Messages.new
  unless detached
    if stdin
      excon_params[:hijack_block] = Docker::Util.hijack_for(stdin, block,
        msgs, tty)
    else
      excon_params[:response_block] = Docker::Util.attach_for(block,
        msgs, tty)
    end
  end

  excon_params[:read_timeout] = read_timeout unless read_timeout.nil?

  connection.post(path_for(:start), nil, excon_params)
  [msgs.stdout_messages, msgs.stderr_messages, self.json['ExitCode']]
end