dockerun 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dockerspec.sample +3 -0
- data/exe/dockerun +8 -1
- data/lib/dockerun/cli/command.rb +15 -8
- data/lib/dockerun/cli/command_factory.rb +3 -0
- data/lib/dockerun/cli/delete_container.rb +15 -11
- data/lib/dockerun/cli/delete_image.rb +24 -20
- data/lib/dockerun/cli/run.rb +3 -2
- data/lib/dockerun/cli_engine.rb +42 -24
- data/lib/dockerun/config.rb +12 -0
- data/lib/dockerun/dsl.rb +57 -6
- data/lib/dockerun/version.rb +1 -1
- data/lib/dockerun.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f23fcd1952170862f9d4f21a19f96c3ee7f7c8ff0eab469262c5f5590ada14f
|
4
|
+
data.tar.gz: 2604672593f83ce0aa96d31e7998de3f4a0504ae42b87c09df4d977dee611689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cccad096ed827b5193427966a2ca6268063679e757441ec3c19a71248509841912b885e0c4c725bfdb8c6c22c5f13da54b93d8cf6e42d222f63a954a77d95429
|
7
|
+
data.tar.gz: ba055de454e07969dc9f31f3f30807c839b663ca5a77a72b69b992d111b339db1c7be81007cd4be7531fb0e45f827ab71d972646e96dbf4f9b39f42737d6aa29
|
data/dockerspec.sample
CHANGED
data/exe/dockerun
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative '../lib/dockerun'
|
4
4
|
|
5
|
+
require 'colorize'
|
6
|
+
|
5
7
|
# Operations
|
6
8
|
# 1. [i]nit - Copy sample spec into project dir
|
7
9
|
# 2. [r]un - Run the spec (default without params)
|
@@ -10,5 +12,10 @@ require_relative '../lib/dockerun'
|
|
10
12
|
# 5. reset - Delete container and image
|
11
13
|
|
12
14
|
cli = Dockerun::CliEngine.new
|
13
|
-
|
15
|
+
begin
|
16
|
+
cli.parse_argv(ARGV)
|
17
|
+
rescue TR::ArgUtils::RequiredFieldEmpty => ex
|
18
|
+
STDERR.puts "\n Operation requires parameter. Error was : #{ex.message}".red
|
19
|
+
puts cli.parse_argv(["help"])
|
20
|
+
end
|
14
21
|
|
data/lib/dockerun/cli/command.rb
CHANGED
@@ -17,12 +17,12 @@ module Dockerun
|
|
17
17
|
attr_accessor :command_buffer
|
18
18
|
def initialize(cmd, required_interaction = false)
|
19
19
|
|
20
|
-
cmdOut = ENV["DOCKERUN_COMMAND_OUT"]
|
21
|
-
if not_empty?(cmdOut)
|
22
|
-
|
23
|
-
else
|
24
|
-
|
25
|
-
end
|
20
|
+
#cmdOut = ENV["DOCKERUN_COMMAND_OUT"]
|
21
|
+
#if not_empty?(cmdOut)
|
22
|
+
# @runner = TTY::Command.new(printer: cmdOut.to_sym)
|
23
|
+
#else
|
24
|
+
# @runner = TTY::Command.new(printer: :null)
|
25
|
+
#end
|
26
26
|
|
27
27
|
#@runner = TTY::Command.new
|
28
28
|
@command_buffer = cmd
|
@@ -34,7 +34,7 @@ module Dockerun
|
|
34
34
|
@required_interaction
|
35
35
|
end
|
36
36
|
|
37
|
-
def run(&block)
|
37
|
+
def run(log_console = false, &block)
|
38
38
|
|
39
39
|
if interactive_session?
|
40
40
|
|
@@ -88,7 +88,14 @@ module Dockerun
|
|
88
88
|
else
|
89
89
|
@outStream = []
|
90
90
|
@errStream = []
|
91
|
-
|
91
|
+
|
92
|
+
if(log_console)
|
93
|
+
runner = TTY::Command.new(printer: :pretty)
|
94
|
+
else
|
95
|
+
runner = TTY::Command.new(printer: :null)
|
96
|
+
end
|
97
|
+
|
98
|
+
result = runner.run!(@command_buffer.join(" ")) do |out, err|
|
92
99
|
if block
|
93
100
|
block.call(:outstream, out)
|
94
101
|
block.call(:errstream, err)
|
@@ -13,6 +13,7 @@ module Dockerun
|
|
13
13
|
|
14
14
|
opts = { } if opts.nil?
|
15
15
|
cmd = []
|
16
|
+
cmd << "cd #{opts[:working_dir]} && " if not_empty?(opts[:working_dir])
|
16
17
|
cmd << DockerCli.docker_exe
|
17
18
|
cmd << "build"
|
18
19
|
if not_empty?(name)
|
@@ -168,6 +169,7 @@ module Dockerun
|
|
168
169
|
Command.new(cmd, (interactive ? true : false))
|
169
170
|
end # run_container_from_image
|
170
171
|
|
172
|
+
|
171
173
|
def start_container(container, opts = { })
|
172
174
|
|
173
175
|
opts = {} if opts.nil?
|
@@ -181,6 +183,7 @@ module Dockerun
|
|
181
183
|
Command.new(cmd)
|
182
184
|
end
|
183
185
|
|
186
|
+
|
184
187
|
def attach_container(container, opts = { })
|
185
188
|
|
186
189
|
opts = {} if opts.nil?
|
@@ -9,7 +9,12 @@ module Dockerun
|
|
9
9
|
|
10
10
|
class DeleteContainer
|
11
11
|
|
12
|
-
def
|
12
|
+
def initialize
|
13
|
+
@proxy = DSLProxy.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def start(root)
|
17
|
+
@proxy.set_exec_root(root)
|
13
18
|
begin
|
14
19
|
pmt.puts " Dockerun version #{Dockerun::VERSION}".yellow
|
15
20
|
pmt.puts " Operational : Delete Container"
|
@@ -19,23 +24,22 @@ module Dockerun
|
|
19
24
|
end
|
20
25
|
|
21
26
|
def delete_container
|
22
|
-
selSpec = CliEngine.select_spec
|
27
|
+
selSpec = CliEngine.select_spec(@proxy.exec_root)
|
23
28
|
cont = File.read(selSpec)
|
24
|
-
proxy
|
25
|
-
proxy.
|
26
|
-
proxy.instance_eval(cont)
|
29
|
+
@proxy.set_dry_run_mode
|
30
|
+
@proxy.instance_eval(cont)
|
27
31
|
|
28
|
-
skip = pmt.no?(" Delete container named '#{proxy.container_name}'?")
|
32
|
+
skip = pmt.no?(" Delete container named '#{@proxy.container_name}'?")
|
29
33
|
if not skip
|
30
|
-
cf.stop_container(proxy.container_name).run
|
31
|
-
res = cf.delete_container(proxy.container_name).run
|
34
|
+
cf.stop_container(@proxy.container_name).run
|
35
|
+
res = cf.delete_container(@proxy.container_name).run
|
32
36
|
if res.success?
|
33
|
-
pmt.puts " Container '#{proxy.container_name}' deleted".green
|
37
|
+
pmt.puts " Container '#{@proxy.container_name}' deleted".green
|
34
38
|
else
|
35
|
-
pmt.puts " Container '#{proxy.container_name}' deletion failed. Error was : #{res.err_lines.join("\n")}".red
|
39
|
+
pmt.puts " Container '#{@proxy.container_name}' deletion failed. Error was : #{res.err_lines.join("\n")}".red
|
36
40
|
end
|
37
41
|
else
|
38
|
-
pmt.puts " Container deletion of name '#{proxy.container_name}' aborted.".yellow
|
42
|
+
pmt.puts " Container deletion of name '#{@proxy.container_name}' aborted.".yellow
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -10,7 +10,12 @@ module Dockerun
|
|
10
10
|
class DeleteImage
|
11
11
|
include TR::CondUtils
|
12
12
|
|
13
|
-
def
|
13
|
+
def initialize
|
14
|
+
@proxy = DSLProxy.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def start(root)
|
18
|
+
@proxy.set_exec_root(root)
|
14
19
|
begin
|
15
20
|
pmt.puts " Dockerun version #{Dockerun::VERSION}".yellow
|
16
21
|
pmt.puts " Operational : Delete Image"
|
@@ -20,20 +25,19 @@ module Dockerun
|
|
20
25
|
end
|
21
26
|
|
22
27
|
def delete_image
|
23
|
-
selSpec = CliEngine.select_spec
|
28
|
+
selSpec = CliEngine.select_spec(@proxy.exec_root)
|
24
29
|
cont = File.read(selSpec)
|
25
|
-
proxy
|
26
|
-
proxy.
|
27
|
-
proxy.instance_eval(cont)
|
30
|
+
@proxy.set_dry_run_mode
|
31
|
+
@proxy.instance_eval(cont)
|
28
32
|
|
29
|
-
res = cf.find_image(proxy.image_name).run
|
33
|
+
res = cf.find_image(@proxy.image_name).run
|
30
34
|
if res.success?
|
31
35
|
if not_empty?(res.output_lines)
|
32
36
|
|
33
|
-
skip = pmt.no?(" Delete image named '#{proxy.image_name}'?")
|
37
|
+
skip = pmt.no?(" Delete image named '#{@proxy.image_name}'?")
|
34
38
|
if not skip
|
35
|
-
res = cf.find_container_names_by_image_name(proxy.image_name, all_containers: true).run
|
36
|
-
raise Error, "Failed to extract container name by image name '#{proxy.image_name}'" if not res.success?
|
39
|
+
res = cf.find_container_names_by_image_name(@proxy.image_name, all_containers: true).run
|
40
|
+
raise Error, "Failed to extract container name by image name '#{@proxy.image_name}'" if not res.success?
|
37
41
|
|
38
42
|
if not_empty?(res.output_lines)
|
39
43
|
cont = []
|
@@ -41,45 +45,45 @@ module Dockerun
|
|
41
45
|
res.output_lines.each do |l|
|
42
46
|
cont << " #{cnt += 1}. #{l}"
|
43
47
|
end
|
44
|
-
skip = pmt.no?(" All the containers shall be deleted prior to image '#{proxy.image_name}' deletion. Proceed?\n#{cont.join("\n")}")
|
48
|
+
skip = pmt.no?(" All the containers shall be deleted prior to image '#{@proxy.image_name}' deletion. Proceed?\n#{cont.join("\n")}")
|
45
49
|
if not skip
|
46
50
|
res.output_lines.each do |ci|
|
47
51
|
cf.stop_container(ci).run
|
48
52
|
cf.delete_container(ci).run
|
49
53
|
end
|
50
54
|
|
51
|
-
res = cf.delete_image(proxy.image_name).run
|
55
|
+
res = cf.delete_image(@proxy.image_name).run
|
52
56
|
if res.success?
|
53
|
-
pmt.puts " Image '#{proxy.image_name}' deleted".green
|
57
|
+
pmt.puts " Image '#{@proxy.image_name}' deleted".green
|
54
58
|
else
|
55
|
-
raise Error, " Image '#{proxy.image_name}' deletion failed. Error was : #{res.err_lines.join("\n")}"
|
59
|
+
raise Error, " Image '#{@proxy.image_name}' deletion failed. Error was : #{res.err_lines.join("\n")}"
|
56
60
|
end
|
57
61
|
|
58
62
|
else
|
59
|
-
pmt.puts " Delete of image '#{proxy.image_name}' aborted".yellow
|
63
|
+
pmt.puts " Delete of image '#{@proxy.image_name}' aborted".yellow
|
60
64
|
end
|
61
65
|
|
62
66
|
else
|
63
|
-
res = cf.delete_image(proxy.image_name).run
|
67
|
+
res = cf.delete_image(@proxy.image_name).run
|
64
68
|
if res.success?
|
65
|
-
pmt.puts " Image '#{proxy.image_name}' deleted".green
|
69
|
+
pmt.puts " Image '#{@proxy.image_name}' deleted".green
|
66
70
|
else
|
67
|
-
raise Error, " Image '#{proxy.image_name}' deletion failed. Error was : #{res.err_lines.join("\n")}"
|
71
|
+
raise Error, " Image '#{@proxy.image_name}' deletion failed. Error was : #{res.err_lines.join("\n")}"
|
68
72
|
end
|
69
73
|
|
70
74
|
end
|
71
75
|
|
72
76
|
else
|
73
|
-
pmt.puts " Delete of image '#{proxy.image_name}' aborted".yellow
|
77
|
+
pmt.puts " Delete of image '#{@proxy.image_name}' aborted".yellow
|
74
78
|
|
75
79
|
end
|
76
80
|
|
77
81
|
else
|
78
|
-
pmt.puts " Image '#{proxy.image_name}' does not exist".green
|
82
|
+
pmt.puts " Image '#{@proxy.image_name}' does not exist".green
|
79
83
|
end
|
80
84
|
|
81
85
|
else
|
82
|
-
pmt.puts " Failed to find image '#{proxy.image_name}'. Error was : #{res.err_lines.join("\n")}"
|
86
|
+
pmt.puts " Failed to find image '#{@proxy.image_name}'. Error was : #{res.err_lines.join("\n")}"
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
data/lib/dockerun/cli/run.rb
CHANGED
@@ -8,7 +8,8 @@ module Dockerun
|
|
8
8
|
#include TR::ArgUtils
|
9
9
|
include DSL
|
10
10
|
|
11
|
-
def start
|
11
|
+
def start(root)
|
12
|
+
set_exec_root(root)
|
12
13
|
begin
|
13
14
|
pmt.puts " Dockerun version #{Dockerun::VERSION}".yellow
|
14
15
|
pmt.puts " Operational : Run Spec"
|
@@ -20,7 +21,7 @@ module Dockerun
|
|
20
21
|
|
21
22
|
private
|
22
23
|
def load_spec
|
23
|
-
selSpec = CliEngine.select_spec
|
24
|
+
selSpec = CliEngine.select_spec(exec_root)
|
24
25
|
pmt.puts " Loading spec '#{selSpec}"
|
25
26
|
cont = File.read(selSpec)
|
26
27
|
self.instance_eval(cont)
|
data/lib/dockerun/cli_engine.rb
CHANGED
@@ -9,26 +9,26 @@ module Dockerun
|
|
9
9
|
include TR::ArgUtils
|
10
10
|
|
11
11
|
arg_spec do
|
12
|
-
opt "i", "Initialize sample dockerspec at
|
13
|
-
init
|
12
|
+
opt "i", "Initialize sample dockerspec at given directory as next argument" do |v|
|
13
|
+
init(v)
|
14
14
|
end
|
15
15
|
opt_alias "i", "init"
|
16
16
|
|
17
|
-
opt "r", "Run the dockerspec" do
|
18
|
-
run
|
17
|
+
opt "r", "Run the dockerspec at given directory as next argument" do |v|
|
18
|
+
run(v)
|
19
19
|
end
|
20
20
|
opt_alias "r","run"
|
21
21
|
|
22
|
-
opt "dc", "Delete container" do
|
23
|
-
delete_container
|
22
|
+
opt "dc", "Delete container at given directory as next argument" do |v|
|
23
|
+
delete_container(v)
|
24
24
|
end
|
25
25
|
|
26
|
-
opt "di", "Delete image and its associated container(s)" do
|
27
|
-
delete_image
|
26
|
+
opt "di", "Delete image and its associated container(s) at given directory as next argument" do |v|
|
27
|
+
delete_image(v)
|
28
28
|
end
|
29
29
|
|
30
|
-
opt 'clean', "Clean generated Dockerfile and temporary files" do
|
31
|
-
clean_env
|
30
|
+
opt 'clean', "Clean generated Dockerfile and temporary files at given directory as next argument" do |v|
|
31
|
+
clean_env(v)
|
32
32
|
end
|
33
33
|
|
34
34
|
opt 'help', "Command help" do
|
@@ -49,8 +49,11 @@ module Dockerun
|
|
49
49
|
pmt.puts ""
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.select_spec
|
53
|
-
|
52
|
+
def self.select_spec(root)
|
53
|
+
raise InsufficientParameter, "Given path cannot be empty or nil" if is_empty?(root)
|
54
|
+
|
55
|
+
#sel = Dir.entries(Dir.getwd).sort
|
56
|
+
sel = Dir.entries(root).sort
|
54
57
|
default = sel.select { |e| (e =~ /^dockerspec/) != nil }
|
55
58
|
selSpec = pmt.select(" Please select the dockerspec to proceed : ", filter: true, default: default.first) do |m|
|
56
59
|
sel.each do |s|
|
@@ -63,34 +66,49 @@ module Dockerun
|
|
63
66
|
end
|
64
67
|
|
65
68
|
|
66
|
-
def init
|
69
|
+
def init(root)
|
70
|
+
raise InsufficientParameter, "Given path cannot be empty or nil" if is_empty?(root)
|
71
|
+
|
72
|
+
root = File.expand_path(root)
|
67
73
|
template = File.join(File.dirname(__FILE__),"..","..","dockerspec.sample")
|
68
74
|
if File.exist?(template)
|
69
|
-
FileUtils.cp template, File.join(Dir.getwd, "dockerspec.sample")
|
75
|
+
#FileUtils.cp template, File.join(Dir.getwd, "dockerspec.sample")
|
76
|
+
FileUtils.cp template, File.join(root, "dockerspec.sample")
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
73
|
-
def run
|
80
|
+
def run(root)
|
81
|
+
raise InsufficientParameter, "Given path cannot be empty or nil" if is_empty?(root)
|
82
|
+
|
83
|
+
root = File.expand_path(root)
|
74
84
|
r = Dockerun::Cli::Run.new
|
75
|
-
r.start
|
85
|
+
r.start(root)
|
76
86
|
end
|
77
87
|
|
78
|
-
def delete_container
|
88
|
+
def delete_container(root)
|
89
|
+
raise InsufficientParameter, "Given path cannot be empty or nil" if is_empty?(root)
|
90
|
+
root = File.expand_path(root)
|
79
91
|
d = Dockerun::Cli::DeleteContainer.new
|
80
|
-
d.start
|
92
|
+
d.start(root)
|
81
93
|
end
|
82
94
|
|
83
|
-
def delete_image
|
95
|
+
def delete_image(root)
|
96
|
+
raise InsufficientParameter, "Given path cannot be empty or nil" if is_empty?(root)
|
97
|
+
root = File.expand_path(root)
|
84
98
|
d = Dockerun::Cli::DeleteImage.new
|
85
|
-
d.start
|
99
|
+
d.start(root)
|
86
100
|
end
|
87
101
|
|
88
|
-
def clean_env
|
89
|
-
|
102
|
+
def clean_env(root)
|
103
|
+
raise InsufficientParameter, "Given path cannot be empty or nil" if is_empty?(root)
|
104
|
+
root = File.expand_path(root)
|
105
|
+
|
106
|
+
Dir.glob(File.join(root,"Dockerfile-*")).each do |f|
|
90
107
|
FileUtils.rm(f)
|
91
108
|
end
|
92
|
-
|
93
|
-
|
109
|
+
pa = File.join(root,"script_for_gem.sh")
|
110
|
+
FileUtils.rm(pa) if File.exist?(pa)
|
111
|
+
self.class.pmt.puts " Generated Dockerfile-* and script_for_gem.sh is deleted at '#{root}'".green
|
94
112
|
end
|
95
113
|
|
96
114
|
def self.pmt
|
data/lib/dockerun/config.rb
CHANGED
@@ -52,6 +52,18 @@ module Dockerun
|
|
52
52
|
@active_context
|
53
53
|
end
|
54
54
|
|
55
|
+
|
56
|
+
def gen_docker_runscript(bool = true, overwrite = false)
|
57
|
+
@_gen_docker_runscript = bool
|
58
|
+
@_overwrite_docker_runscript = overwrite
|
59
|
+
end
|
60
|
+
def is_gen_docker_runscript?
|
61
|
+
@_gen_docker_runscript.nil? ? false : @_gen_docker_runscript
|
62
|
+
end
|
63
|
+
def is_overwrite_docker_runscript?
|
64
|
+
@_overwrite_docker_runscript.nil? ? false : @_overwrite_docker_runscript
|
65
|
+
end
|
66
|
+
|
55
67
|
|
56
68
|
def dry_run(bool = true, prompt = true)
|
57
69
|
@dry_run = bool
|
data/lib/dockerun/dsl.rb
CHANGED
@@ -9,6 +9,13 @@ module Dockerun
|
|
9
9
|
module DSL
|
10
10
|
include TR::CondUtils
|
11
11
|
|
12
|
+
def set_exec_root(root)
|
13
|
+
@_exec_root = root
|
14
|
+
end
|
15
|
+
def exec_root
|
16
|
+
@_exec_root
|
17
|
+
end
|
18
|
+
|
12
19
|
def config(&block)
|
13
20
|
_config.instance_eval(&block)
|
14
21
|
end
|
@@ -176,19 +183,30 @@ module Dockerun
|
|
176
183
|
|
177
184
|
def build_image
|
178
185
|
dfile = _dfile.generate
|
179
|
-
dfileName = "Dockerfile-#{SecureRandom.hex(4)}"
|
186
|
+
dfileName = File.join(exec_root,"Dockerfile-#{SecureRandom.hex(4)}")
|
180
187
|
File.open(dfileName,"w") do |f|
|
181
188
|
f.write dfile
|
182
189
|
end
|
183
190
|
|
184
|
-
fact = docker_cf.build_image(image_name, dockerfile: dfileName)
|
191
|
+
fact = docker_cf.build_image(image_name, dockerfile: dfileName, working_dir: exec_root)
|
192
|
+
|
193
|
+
if _config.is_gen_docker_runscript?
|
194
|
+
out = File.join(exec_root,"1.build-image.sh")
|
195
|
+
if (not File.exist?(out)) or _config.is_overwrite_docker_runscript?
|
196
|
+
File.open(out, "w") do |f|
|
197
|
+
f.puts "#!/bin/sh"
|
198
|
+
f.puts fact.to_s
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
185
203
|
if _config.is_dry_run?
|
186
204
|
dry_run_puts "Build Image : #{fact.to_s}"
|
187
205
|
dry_run_puts "Build Image : Returning true to proceed to next phase."
|
188
206
|
dry_run_puts "Generated dockerfile '#{dfileName}' shall be remained in project directory."
|
189
207
|
[true, nil]
|
190
208
|
else
|
191
|
-
res = fact.run
|
209
|
+
res = fact.run(true)
|
192
210
|
if res.success?
|
193
211
|
FileUtils.rm(dFileName) if not _dfile.keep_dockerfile?
|
194
212
|
[true, res]
|
@@ -234,6 +252,16 @@ module Dockerun
|
|
234
252
|
fact = docker_cf.find_running_container(container_name)
|
235
253
|
fact2 = docker_cf.start_container(container_name)
|
236
254
|
|
255
|
+
if _config.is_gen_docker_runscript?
|
256
|
+
out = File.join(exec_root,"3.start-container.sh")
|
257
|
+
if (not File.exist?(out)) or _config.is_overwrite_docker_runscript?
|
258
|
+
File.open(out, "w") do |f|
|
259
|
+
f.puts "#!/bin/sh"
|
260
|
+
f.puts fact.to_s
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
237
265
|
if _config.is_dry_run?
|
238
266
|
dry_run_puts "Find running container : #{fact.to_s}"
|
239
267
|
dry_run_puts "Start container : #{fact2.to_s}"
|
@@ -252,12 +280,23 @@ module Dockerun
|
|
252
280
|
|
253
281
|
def attach_container
|
254
282
|
fact = docker_cf.attach_container(container_name)
|
283
|
+
|
284
|
+
if _config.is_gen_docker_runscript?
|
285
|
+
out = File.join(exec_root,"4.attach-container.sh")
|
286
|
+
if (not File.exist?(out)) or _config.is_overwrite_docker_runscript?
|
287
|
+
File.open(out, "w") do |f|
|
288
|
+
f.puts "#!/bin/sh"
|
289
|
+
f.puts fact.to_s
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
255
294
|
if _config.is_dry_run?
|
256
295
|
dry_run_puts "Attach container : #{fact.to_s}"
|
257
296
|
else
|
258
297
|
fact.run
|
259
298
|
end
|
260
|
-
|
299
|
+
|
261
300
|
end
|
262
301
|
|
263
302
|
def run_container
|
@@ -267,9 +306,21 @@ module Dockerun
|
|
267
306
|
params[:ports] = {} if params[:ports].nil?
|
268
307
|
params[:ports].merge!(_docker_cli.expose_ports) if _docker_cli.has_exposed_ports?
|
269
308
|
|
270
|
-
|
309
|
+
rparams = _docker_cli.trigger_listener(:docker_cli_construct_command, params)
|
310
|
+
rparams = params if is_empty?(rparams)
|
311
|
+
|
312
|
+
fact = docker_cf.create_container_from_image(image_name, rparams)
|
313
|
+
|
314
|
+
if _config.is_gen_docker_runscript?
|
315
|
+
out = File.join(exec_root,"2.create-container.sh")
|
316
|
+
if (not File.exist?(out)) or _config.is_overwrite_docker_runscript?
|
317
|
+
File.open(out, "w") do |f|
|
318
|
+
f.puts "#!/bin/sh"
|
319
|
+
f.puts fact.to_s
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
271
323
|
|
272
|
-
fact = docker_cf.create_container_from_image(image_name, params)
|
273
324
|
if _config.is_dry_run?
|
274
325
|
dry_run_puts "Run container : #{fact.to_s}"
|
275
326
|
else
|
data/lib/dockerun/version.rb
CHANGED
data/lib/dockerun.rb
CHANGED