def exec(command, options = {}, &block)
tty = options.delete(:tty) || false
detach = options.delete(:detach) || false
user = options.delete(:user)
stdin = options.delete(:stdin)
stdout = options.delete(:stdout) || !detach
stderr = options.delete(:stderr) || !detach
wait = options.delete(:wait)
opts = {
'Container' => self.id,
'User' => user,
'AttachStdin' => !!stdin,
'AttachStdout' => stdout,
'AttachStderr' => stderr,
'Tty' => tty,
'Cmd' => command
}.merge(options)
instance = Docker::Exec.create(
opts,
self.connection
)
start_opts = {
:tty => tty,
:stdin => stdin,
:detach => detach,
:wait => wait
}
if detach
instance.start!(start_opts)
return instance
else
instance.start!(start_opts, &block)
end
end