lib/mkit/app/helpers/docker_helper.rb in mkit-0.4.1 vs lib/mkit/app/helpers/docker_helper.rb in mkit-0.4.2
- old
+ new
@@ -1,10 +1,11 @@
+# frozen_string_literal: true
+
require 'mkit/cmd_runner'
module MKIt
module DockerHelper
-
# from ERB template
def create_instance(cmd)
MKIt::CmdRunner.run(cmd)
end
@@ -20,11 +21,11 @@
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}}
+ 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}")
@@ -37,10 +38,10 @@
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 = 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}")