Method: Docker::Container#attach
- Defined in:
- lib/docker/container.rb
#attach(options = {}, &block) ⇒ Object
Attach to a container’s standard streams / logs.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/docker/container.rb', line 42 def attach( = {}, &block) stdin = .delete(:stdin) opts = { :stream => true, :stdout => true, :stderr => true }.merge() # Creates list to store stdout and stderr messages msgs = Docker::Messages.new excon_params = {} if stdin # If attaching to stdin, we must hijack the underlying TCP connection # so we can stream stdin to the remote Docker process opts[:stdin] = true excon_params[:hijack_block] = hijack_for(stdin, block, msgs) else excon_params[:response_block] = attach_for(block, msgs) end connection.post( path_for(:attach), opts, excon_params ) [msgs., msgs.] end |