Class: Docker::Container
- Inherits:
-
Object
- Object
- Docker::Container
- Defined in:
- lib/brick/monkey_patches/docker_container.rb
Class Method Summary collapse
-
.exist?(id, opts = {}, conn = Docker.connection) ⇒ Boolean
Check if an image exists.
- .search_by_name(name_filter, conn, query = {"all"=>true}) ⇒ Object
Instance Method Summary collapse
Class Method Details
.exist?(id, opts = {}, conn = Docker.connection) ⇒ Boolean
Check if an image exists.
22 23 24 25 26 27 |
# 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}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# 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 |
Instance Method Details
#is_running? ⇒ Boolean
17 18 19 |
# File 'lib/brick/monkey_patches/docker_container.rb', line 17 def is_running? running= Docker::Container.get(id).info["State"]["Running"] end |