Method: Docker::Compose::Session#run!

Defined in:
lib/docker/compose/session.rb

#run!(*args) ⇒ String

Run a docker-compose command without validating that the CLI parameters make sense. Prepend project and file options if suitable.

Raises:

  • (Error)

    if command fails

See Also:

  • Docker::Compose::Shell#command


220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/docker/compose/session.rb', line 220

def run!(*args)
  file_args = case @file
  when 'docker-compose.yml'
    []
  when Array
    # backticks sugar can't handle array values; build a list of hashes
    # IMPORTANT: preserve the order of the files so overrides work correctly
    file_args = @file.map { |filepath| { :file => filepath } }
  else
    # a single String (or Pathname, etc); use normal sugar to add it
    [{ file: @file.to_s }]
  end

  @shell.chdir = dir
  cmd = @shell.run('docker-compose', *file_args, *args).join
  status = cmd.status
  out = cmd.captured_output
  err = cmd.captured_error
  status.success? || fail(Error.new(args.first, status, out+err))
  out
end