28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/dockerun/command/run_new_container.rb', line 28
def run
if params[:help]
print help
exit(0)
else
config = ::Dockerun::Config.from_storage
imageName = nil
if is_empty?(config.image_names)
STDERR.puts "Image name not availab eyet"
exit(1)
elsif config.image_names == 1
imageName = config.image_names.first
else
imageName = cli.select("Please select the new container shall be based on which image : ") do |m|
config.image_names.each do |n|
m.choice n,n
end
end
end
contName = run_docker_container(imageName, nil) do |ops, *args|
case ops
when :new_container_name
cli.ask("Please provide a new container name : ", required: true)
when :container_name_exist
cli.yes?("Container name '#{args.first}' already exist. Proceed with existing?")
when :volume_mapping_required?
cli.yes?("Is there any volume mapping required? ")
when :source_prompt
cli.ask("Directory to share with docker : ", required: true)
when :destination_prompt
src = args.first
srcDir = File.basename(src)
cli.ask("Directory to show inside docker : ", required: true, value: "/opt/#{srcDir}")
when :add_mount_to_container
config.add_mount_to_container(imageName, *args)
when :add_more_volume_mapping?
cli.yes?("Add more volume mapping?")
end
end
config.add_container(imageName, contName)
config.to_storage
end
end
|