class Docker::Container

Public Class Methods

exist?(id, opts = {}, conn = Docker.connection) click to toggle source

Check if an image exists.

# File lib/brick/monkey_patches/docker_container.rb, line 22
def self.exist?(id, opts = {}, conn = Docker.connection)
  get(id, opts, conn)
  true
rescue Docker::Error::NotFoundError
  false
end
search_by_name(name_filter, conn, query={"all"=>true}) click to toggle source
# File lib/brick/monkey_patches/docker_container.rb, line 5
def self.search_by_name(name_filter, conn, query={"all"=>true})
  result=[]
  hashes = Docker::Util.parse_json(conn.get('/containers/json', query)) || []
  list=hashes.map { |hash| Docker::Container.get(hash["Id"]) }
  
  list = list.select{|e| e.info["Name"].include? name_filter}
  
  result=list.sort_by{|e| -Date.parse(e.info["Created"]).to_time.to_i}
  
  return result
end

Public Instance Methods

is_running?() click to toggle source
# File lib/brick/monkey_patches/docker_container.rb, line 17
def is_running?
 running= Docker::Container.get(id).info["State"]["Running"] 
end