Sha256: 212cfa0a0bba5b65c9297c7eea0b193e0a5f0e643c1b1b279a2eafc266da5f1a
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 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) command_parts = [] command_parts << "docker run" 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
4 entries across 4 versions & 1 rubygems