class Centurion::DockerServer
Attributes
hostname[R]
port[R]
Public Class Methods
new(host, docker_path, tls_params = {})
click to toggle source
# File lib/centurion/docker_server.rb, line 21 def initialize(host, docker_path, tls_params = {}) @docker_path = docker_path @hostname, @port = host.split(':') @port ||= '2375' @tls_params = tls_params end
Public Instance Methods
find_container_by_id(container_id)
click to toggle source
# File lib/centurion/docker_server.rb, line 53 def find_container_by_id(container_id) ps.find { |container| container && container['Id'] == container_id } end
find_containers_by_name(wanted_name)
click to toggle source
# File lib/centurion/docker_server.rb, line 44 def find_containers_by_name(wanted_name) ps.select do |container| next unless container && container['Names'] container['Names'].find do |name| name =~ /\A\/#{wanted_name}(-[a-f0-9]{14})?\Z/ end end end
find_containers_by_public_port(public_port, type='tcp')
click to toggle source
# File lib/centurion/docker_server.rb, line 35 def find_containers_by_public_port(public_port, type='tcp') ps.select do |container| next unless container && container['Ports'] container['Ports'].find do |port| port['PublicPort'] == public_port.to_i && port['Type'] == type end end end
old_containers_for_name(wanted_name)
click to toggle source
# File lib/centurion/docker_server.rb, line 57 def old_containers_for_name(wanted_name) find_containers_by_name(wanted_name).select do |container| container["Status"] =~ /^(Exit |Exited)/ end end
Private Instance Methods
docker_via_api()
click to toggle source
# File lib/centurion/docker_server.rb, line 65 def docker_via_api @docker_via_api ||= Centurion::DockerViaApi.new(@hostname, @port, @tls_params, nil) end
docker_via_cli()
click to toggle source
# File lib/centurion/docker_server.rb, line 70 def docker_via_cli @docker_via_cli ||= Centurion::DockerViaCli.new(@hostname, @port, @docker_path, @tls_params) end