Class: MysqlInDocker::Commands

Inherits:
Thor
  • Object
show all
Defined in:
lib/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#rm(id) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/commands.rb', line 38

def rm(id)
  stop id

  status = docker_command "volume rm #{get_container_name(id)}"
  if status[:stderr].include? "No such volume:"
    p "Volume not found."
  else
    p "Removed volume."
  end
end

#start(id, version, port, mysql_root_password) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/commands.rb', line 13

def start(id, version, port, mysql_root_password)
  status = docker_command "start #{get_container_name(id)}"
  if status[:successed]
    p "#{get_container_name(id)} running on #{port}."
    return
  end

  command = up_command id, version, port, mysql_root_password
  status = docker_command(command)
  raise_if_status_failed status

  p "Created #{get_container_name(id)} on #{port}."
end

#stop(id) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/commands.rb', line 28

def stop(id)
  status = docker_command "rm -f #{get_container_name(id)}"
  if status[:stderr].include? "No such container:"
    p "Container not found."
  else
    p "Removed container."
  end
end