Class: Aruba::DockerRunCommandLineBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/aruba/tasks/docker_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(run_instance, opts = {}) ⇒ DockerRunCommandLineBuilder

Returns a new instance of DockerRunCommandLineBuilder.


71
72
73
74
# File 'lib/aruba/tasks/docker_helpers.rb', line 71

def initialize(run_instance, opts = {})
  @run_instance = run_instance
  @opts         = opts
end

Instance Method Details

#to_cliObject


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/aruba/tasks/docker_helpers.rb', line 76

def to_cli
  volumes = run_instance.volumes
  image   = run_instance.image
  command = opts[:command]

  cmdline = []
  cmdline << 'docker'
  cmdline << 'run'
  cmdline << '-it'
  cmdline << '--rm'
  cmdline << "--name #{run_instance.container_name}"

  volumes.each do |v|
    cmdline << "-v #{expand_volume_paths(v)}"
  end

  cmdline << image
  cmdline << command if command

  cmdline.join(' ')
end