Class: Avm::Docker::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/docker/container.rb

Instance Method Summary collapse

Instance Method Details

#removeObject



12
13
14
15
16
# File 'lib/avm/docker/container.rb', line 12

def remove
  ::EacDocker::Executables.docker.command.append(
    ['rm', '--force', instance.docker_container_name]
  ).system!
end

#run(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/avm/docker/container.rb', line 18

def run(options = {})
  infov 'Container name', instance.docker_container_name
  infov 'Container exist?', instance.docker_container_exist?
  remove if options[:clear] && instance.docker_container_exist?
  if instance.docker_container_exist?
    run_start
  else
    run_run(options)
  end
end

#run_run(options) ⇒ Object



29
30
31
32
# File 'lib/avm/docker/container.rb', line 29

def run_run(options)
  infom "\"docker run #{instance.docker_container_name}...\""
  ::EacDocker::Executables.docker.command.append(run_run_arguments(options)).system!
end

#run_run_arguments(options) ⇒ Object



39
40
41
42
43
# File 'lib/avm/docker/container.rb', line 39

def run_run_arguments(options)
  entrypoint_args = options[:entrypoint_args].if_present([])
  ['run', '-it', '--name', instance.docker_container_name] + instance.docker_run_arguments +
    [instance.docker_image.tag] + entrypoint_args
end

#run_startObject



34
35
36
37
# File 'lib/avm/docker/container.rb', line 34

def run_start
  infom "\"docker start #{instance.docker_container_name}...\""
  ::EacDocker::Executables.docker.command.append(run_start_arguments).system!
end

#run_start_argumentsObject



45
46
47
# File 'lib/avm/docker/container.rb', line 45

def run_start_arguments
  ['start', '-ai', instance.docker_container_name]
end