Sha256: 821cf5beaa54db1efb5a06f7f149ed43665618e3b024536f301fa910956ff6b5
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
require 'mkit/cmd_runner' module MKIt module DockerHelper # from ERB template def create_instance(cmd) MKIt::CmdRunner.run(cmd) end def start_instance(instance_id) MKIt::CmdRunner.run("docker start #{instance_id}") end def stop_instance(instance_id) MKIt::CmdRunner.run("docker stop #{instance_id}") end def remove_instance(instance) MKIt::CmdRunner.run("docker rm -f #{instance}") end def inspect_instance(instance_id) # this one does not work on ubunto MKIt::CmdRunner.run("docker inspect #{instance_id}") x = %x{docker inspect #{instance_id}} JSON.parse(x).first end def execute_local(instance_id, cmd) MKIt::CmdRunner.run("docker exec -it #{instance_id} #{cmd}") end # # network # def create_network(network_name) MKIt::CmdRunner.run("docker network create #{network_name}") end def network_exists?(network_name) x = MKIt::CmdRunner.run("docker network ls") x.match(/\b#{network_name}\b/) end def dettach_network(network_id, instance_id) MKIt::CmdRunner.run("docker network disconnect #{network_id} #{instance_id}") end def attach_network(network_id, instance_id) MKIt::CmdRunner.run("docker network connect #{network_id} #{instance_id}") end def remove_network(network_id) MKIt::CmdRunner.run("docker network rm #{network_id}") end # # volumes # def create_volume(volume_name) MKIt::CmdRunner.run("docker volume create #{volume_name}") end def delete_volume(volume_name) MKIt::CmdRunner.run("docker volume rm #{volume_name}") end def inspect_volume(volume_name) x = MKIt::CmdRunner.run("docker volume inspect #{volume_name}") JSON.parse(x).first end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mkit-0.4.1 | lib/mkit/app/helpers/docker_helper.rb |
mkit-0.4.0 | lib/mkit/app/helpers/docker_helper.rb |
mkit-0.3.0 | lib/mkit/app/helpers/docker_helper.rb |