Class: Dockerun::Command::RunNewImage
- Inherits:
-
Object
- Object
- Dockerun::Command::RunNewImage
- Includes:
- Dockerun::CommandHelper::DockerContainerHelper, Dockerun::CommandHelper::DockerImageHelper, DockerCommandFactoryHelper, TR::CondUtils, TTY::Option
- Defined in:
- lib/dockerun/command/run_new_image.rb
Instance Method Summary collapse
Methods included from Dockerun::CommandHelper::DockerImageHelper
#build_image_if_not_exist, #load_dockerfile
Methods included from DockerCommandFactoryHelper
Methods included from Dockerun::CliHelper::CliPrompt
Methods included from Dockerun::CommandHelper::DockerContainerHelper
Instance Method Details
#run(&block) ⇒ Object
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 |
# File 'lib/dockerun/command/run_new_image.rb', line 31 def run(&block) if params[:help] print help exit(0) else # find history file config = ::Dockerun::Config.from_storage imageName = build_image_if_not_exist(imageName) do |ops, val| case ops when :new_image_name cli.ask("Please provide a new image name : ", required: true) when :image_exist reuse = cli.yes? "Image '#{val}' already exist. Using existing image?" # proceed or not , new name [reuse, val] else end end config.add_image(imageName) contNames = config.container_names(imageName) selContName = run_docker_container(imageName, selContName) 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, selContName) config.to_storage end end |