Class: Docker::Cli::ContainerProfile

Inherits:
Object
  • Object
show all
Includes:
TR::CondUtils
Defined in:
lib/docker/cli/docker_container.rb

Overview

only use during creation of new container

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContainerProfile

Returns a new instance of ContainerProfile.



12
13
14
15
16
17
18
19
20
# File 'lib/docker/cli/docker_container.rb', line 12

def initialize
  @interactive = true
  @run_detached = false
  @remove_after_run = false
  @match_user = false
  @run_command = "/bin/bash"
  @mounts = {}
  @ports = {}
end

Instance Attribute Details

#image_nameObject

Returns the value of attribute image_name.



11
12
13
# File 'lib/docker/cli/docker_container.rb', line 11

def image_name
  @image_name
end

#run_commandObject

Returns the value of attribute run_command.



11
12
13
# File 'lib/docker/cli/docker_container.rb', line 11

def run_command
  @run_command
end

Instance Method Details

#add_mount_point(host, inside_docker) ⇒ Object



25
26
27
28
29
# File 'lib/docker/cli/docker_container.rb', line 25

def add_mount_point(host, inside_docker)
  if not_empty?(host) and not_empty?(inside_docker)
    @mounts[host] = inside_docker
  end
end

#add_port_mapping(host, docker) ⇒ Object



34
35
36
37
38
# File 'lib/docker/cli/docker_container.rb', line 34

def add_port_mapping(host, docker)
  if not_empty?(host) and not_empty?(docker)
    @ports[host] = docker
  end
end

#interactive=(val) ⇒ Object



43
44
45
# File 'lib/docker/cli/docker_container.rb', line 43

def interactive=(val)
  @interactive = val
end

#is_interactive?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/docker/cli/docker_container.rb', line 40

def is_interactive?
  @interactive
end

#is_match_user?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/docker/cli/docker_container.rb', line 61

def is_match_user?
  @match_user
end

#is_run_detached?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/docker/cli/docker_container.rb', line 47

def is_run_detached?
  @run_detached
end

#match_user=(val) ⇒ Object



64
65
66
# File 'lib/docker/cli/docker_container.rb', line 64

def match_user=(val)
  @match_user = val
end

#mount_pointsObject



22
23
24
# File 'lib/docker/cli/docker_container.rb', line 22

def mount_points
  @mounts.freeze
end

#portsObject



31
32
33
# File 'lib/docker/cli/docker_container.rb', line 31

def ports
  @ports.freeze
end

#remove_after_run=(val) ⇒ Object



57
58
59
# File 'lib/docker/cli/docker_container.rb', line 57

def remove_after_run=(val)
  @remove_after_run = val 
end

#remove_after_run?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/docker/cli/docker_container.rb', line 54

def remove_after_run?
  @remove_after_run
end

#run_detached=(val) ⇒ Object



50
51
52
# File 'lib/docker/cli/docker_container.rb', line 50

def run_detached=(val)
  @run_detached = val
end

#to_hashObject



68
69
70
71
# File 'lib/docker/cli/docker_container.rb', line 68

def to_hash
  # this returns a hash that match expectation of input in CommandFactory.create_container_from_image
  { interactive: @interactive, tty: @interactive, detached: @run_detached, del: @remove_after_run, mounts: @mounts, ports: @ports, match_user: @match_user, command: @run_command }
end