Method: Docker::Container#exec
- Defined in:
- lib/docker/container.rb
#exec(command, options = {}, &block) ⇒ Docker::Exec
Create an Exec instance inside the container
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 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/docker/container.rb', line 55 def exec(command, = {}, &block) # Establish values tty = .delete(:tty) || false detach = .delete(:detach) || false user = .delete(:user) stdin = .delete(:stdin) stdout = .delete(:stdout) || !detach stderr = .delete(:stderr) || !detach wait = .delete(:wait) opts = { 'Container' => self.id, 'User' => user, 'AttachStdin' => !!stdin, 'AttachStdout' => stdout, 'AttachStderr' => stderr, 'Tty' => tty, 'Cmd' => command }.merge() # Create Exec Instance 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 |