Method: Docker::Compose::Session#run

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

#run(service, *cmd, detached: false, no_deps: false, env: [], rm: false) ⇒ Object

Idempotently run an arbitrary command with a service container.

Parameters:

  • service (String)

    name to run

  • cmd (String)

    command statement to run

  • detached (Boolean) (defaults to: false)

    if true, to start services in the background; otherwise, monitor logs in the foreground and shutdown on Ctrl+C

  • no_deps (Boolean) (defaults to: false)

    if true, just run specified services without running the services that they depend on

  • env (Array) (defaults to: [])

    a list of environment variables (see: -e flag)

  • rm (Boolean) (defaults to: false)

    remove the container when done

Raises:

  • (Error)

    if command fails



116
117
118
119
120
# File 'lib/docker/compose/session.rb', line 116

def run(service, *cmd, detached: false, no_deps: false, env: [], rm: false)
  o = opts(detached: [detached, false], no_deps: [no_deps, false], env: [env, []], rm: [rm, false])
  env_params = env.map { |v| { e: v } }
  run!('run', o, *env_params, service, cmd)
end