Class: KuberKit::Shell::Commands::DockerCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/shell/commands/docker_commands.rb

Instance Method Summary collapse

Instance Method Details

#build(shell, build_dir, args = []) ⇒ Object



2
3
4
5
6
7
# File 'lib/kuber_kit/shell/commands/docker_commands.rb', line 2

def build(shell, build_dir, args = [])
  default_args = ["--rm=true"]
  args_list = (default_args + args).join(" ")

  shell.exec!(%Q{docker build #{build_dir} #{args_list}})
end

#get_container_id(shell, container_name, only_healthy: false, status: "running") ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kuber_kit/shell/commands/docker_commands.rb', line 17

def get_container_id(shell, container_name, only_healthy: false, status: "running")
  command_parts = []
  command_parts << "docker ps -a -q"

  if only_healthy
    command_parts << "--filter=\"health=healthy\""
  end

  command_parts << "--filter=\"status=#{status}\""
  command_parts << "--filter=\"name=#{container_name}\""

  shell.exec!(command_parts.join(" "))
end

#push(shell, tag_name) ⇒ Object



13
14
15
# File 'lib/kuber_kit/shell/commands/docker_commands.rb', line 13

def push(shell, tag_name)
  shell.exec!(%Q{docker push #{tag_name}})
end

#tag(shell, image_name, tag_name) ⇒ Object



9
10
11
# File 'lib/kuber_kit/shell/commands/docker_commands.rb', line 9

def tag(shell, image_name, tag_name)
  shell.exec!(%Q{docker tag #{image_name} #{tag_name}})
end