class Docker::Container
Public Instance Methods
compose()
click to toggle source
# File lib/docker/rails/ext/container.rb, line 55 def compose return nil unless Compose.is_compose_container?(self) @_compose ||= Compose.new(self) end
down?()
click to toggle source
# File lib/docker/rails/ext/container.rb, line 41 def down? !up? end
exit_code()
click to toggle source
# File lib/docker/rails/ext/container.rb, line 45 def exit_code return nil if up? return nil unless (status =~ /xited/) # Up 10 seconds # Exited (0) 2 seconds ago status =~ /^.* \((\w+)\)/ $1.to_i end
name()
click to toggle source
# File lib/docker/rails/ext/container.rb, line 22 def name name = info['Names'][0] unless info['Names'].nil? name = info['Name'] if name.nil? # straight docker containers appear to just use 'Name' # puts "Name: #{info['Name']}" # puts "Names: #{info['Names']}" # puts "Names.nil?: #{info['Names'].nil?}" # puts "Names.length: #{info['Names'].length}" name.gsub(/^\//, '') end
refresh!()
click to toggle source
FIXME: remove this method when pull #321 is accepted
Update the @info hash, which is the only mutable state in this object.
# File lib/docker/rails/ext/container.rb, line 5 def refresh! other = Docker::Container.all({all: true}, connection).find { |c| c.id.start_with?(self.id) || self.id.start_with?(c.id) } info.merge!(self.json) other && info.merge!(other.info) self end
status()
click to toggle source
# File lib/docker/rails/ext/container.rb, line 15 def status # info is cached, return the first one otherwise retrieve a new container and get the status from it refresh! info['Status'] end
up?()
click to toggle source
# File lib/docker/rails/ext/container.rb, line 34 def up? # Up 10 seconds # Exited (0) 2 seconds ago return true if status =~ /^(up|Up)/ false end