Sha256: 320baa4cd116b930b0cc54f8b7d9d6e40e3e296d706b6587b34056ce7b1d2192
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
class KuberKit::Shell::Commands::DockerCommands 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 def tag(shell, image_name, tag_name) shell.exec!(%Q{docker tag #{image_name} #{tag_name}}) end def push(shell, tag_name) shell.exec!(%Q{docker push #{tag_name}}) end def run(shell, image_name, run_args: nil, run_command: nil, detached: false) command_parts = [] command_parts << "docker run" command_parts << "-d" if detached command_parts << run_args if run_args command_parts << image_name command_parts << run_command if run_command shell.exec!(command_parts.join(" ")) end def container_exists?(shell, container_name) result = get_container_id(shell, container_name) result && result != "" end def delete_container(shell, container_name) shell.exec!(%Q{docker rm -f #{container_name}}) end 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kuber_kit-0.3.8 | lib/kuber_kit/shell/commands/docker_commands.rb |
kuber_kit-0.3.7 | lib/kuber_kit/shell/commands/docker_commands.rb |