Sha256: 8ceb6a903274f06f72a6eb0fbc7b389458997fc61b3e3ce1eee2e1658db1a0f1
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'docker/cli' module Dockdev class Container def initialize(name) @cont_name = name @cmd_fact = Docker::Cli::CommandFactory.new end def name @cont_name end def has_container? res = @cmd_fact.find_from_all_container(@cont_name, exact_name: true).run if res.success? not res.is_out_stream_empty? else raise Error, "Command find from all container failed with error : #{res.err_stream}" end end def running? res = @cmd_fact.find_running_container(@cont_name, exact_name: true).run if res.success? not res.is_out_stream_empty? else raise Error, "Command to check is container running failed with error : #{res.err_stream}" end end def attach_and_exec(opts = {}) optss = { tty: true, interactive: true } @cmd_fact.run_command_in_running_container(@cont_name, opts[:command], optss).run end def start_with_command(opts = {}) res = @cmd_fact.start_container(@cont_name).run if res.success? and not res.is_out_stream_empty? attach_and_exec(opts) else raise Error, "Command to start container failed with error : #{res.err_stream}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dockdev-0.1.0 | lib/dockdev/container.rb |