Class: AethernalAgent::Docker::ContainerSettings
- Inherits:
-
Object
- Object
- AethernalAgent::Docker::ContainerSettings
- Defined in:
- lib/aethernal_agent/docker/container_settings.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#port_bindings ⇒ Object
Returns the value of attribute port_bindings.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
4 5 6 |
# File 'lib/aethernal_agent/docker/container_settings.rb', line 4 def env @env end |
#port_bindings ⇒ Object
Returns the value of attribute port_bindings.
4 5 6 |
# File 'lib/aethernal_agent/docker/container_settings.rb', line 4 def port_bindings @port_bindings end |
#volumes ⇒ Object
Returns the value of attribute volumes.
4 5 6 |
# File 'lib/aethernal_agent/docker/container_settings.rb', line 4 def volumes @volumes end |
Class Method Details
.build_from_options(manifest_options, opts) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/aethernal_agent/docker/container_settings.rb', line 5 def self.(, opts) container = ContainerSettings.new container.env = Env.(, opts).collect(&:to_docker) container.port_bindings = PortBinding.(, opts) container.volumes = Volume.(, opts).collect(&:to_docker) return container end |
Instance Method Details
#create_container(name, image) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aethernal_agent/docker/container_settings.rb', line 13 def create_container(name, image) AethernalAgent.logger.debug("Creating Docker container #{name} from image #{image} based on ContainerSettings") AethernalAgent.logger.debug("Env: #{self.env}, Ports; #{self.port_bindings}, Volumes: #{self.volumes}") ::Docker::Container.create( 'name' => name, 'Env' => self.env, 'HostConfig' => { 'RestartPolicy' => {'Name' => 'unless-stopped'}, 'PortBindings' => self.port_bindings, 'Binds' => self.volumes, 'Volumes' => {"/data" => {},"/config" => {}}, }, 'Image' => image, 'Healthcheck' => {'Interval' => 120_000_000_000, 'StartPeriod' => 30_000_000_000} ) end |