Module: Tid::Docker

Defined in:
lib/tid/docker.rb

Class Method Summary collapse

Class Method Details

.buildObject



4
5
6
# File 'lib/tid/docker.rb', line 4

def build
  Console.cmd "docker build -t #{image_name} #{Tid.base_path}"
end

.container_nameObject



40
41
42
# File 'lib/tid/docker.rb', line 40

def container_name
  ENV['TID_CONTAINER_NAME'] || 'tid'
end

.container_ssh_portObject



32
33
34
35
36
37
38
# File 'lib/tid/docker.rb', line 32

def container_ssh_port
  _, _, ex = Console.cmd "docker ps | grep #{container_name}"
  if ex.exitstatus.zero?
    out, _, _ = Console.cmd("docker port #{container_name} 22")
    out.to_s.chomp.gsub('0.0.0.0:', '')
  end
end

.hostnameObject



24
25
26
# File 'lib/tid/docker.rb', line 24

def hostname
  Boot2docker.have? ? Boot2docker.ip : 'localhost'
end

.image_nameObject



28
29
30
# File 'lib/tid/docker.rb', line 28

def image_name
  ENV['TID_IMAGE_NAME'] || 'tid'
end

.rmObject



16
17
18
# File 'lib/tid/docker.rb', line 16

def rm
  Console.cmd "docker rm #{container_name}"
end

.rmiObject



20
21
22
# File 'lib/tid/docker.rb', line 20

def rmi
  Console.cmd "docker rmi #{image_name}"
end

.runObject



8
9
10
# File 'lib/tid/docker.rb', line 8

def run
  Console.cmd "docker run -d -P --name #{container_name} #{image_name}"
end

.stopObject



12
13
14
# File 'lib/tid/docker.rb', line 12

def stop
  Console.cmd "docker stop #{container_name}"
end