Class: Flotte::Command::Docker::Container::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/flotte/command/docker/container/run.rb

Class Method Summary collapse

Class Method Details

.build(image:, name: nil, remove: false, detach: true, interactive: false, command: [], ports: [], extra_arguments: []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/flotte/command/docker/container/run.rb', line 6

def self.build(image:, name: nil, remove: false, detach: true, interactive: false, command: [], ports: [], extra_arguments: [])
  builder = [:docker, "container", "run"]

  builder += ["--name", name] if name.present?

  Array(ports).each do |port_mapping|
    builder += ["--publish", port_mapping]
  end

  builder << "--detach" if detach
  builder << "--rm" if remove
  builder << "-it" if interactive

  builder += Array(extra_arguments)

  builder << image
  builder += Array(command)

  builder
end