Class: DockerSwarm::Container

Inherits:
Base
  • Object
show all
Includes:
DockerSwarm::Concerns::Creatable, DockerSwarm::Concerns::Deletable, DockerSwarm::Concerns::Loggable
Defined in:
lib/docker_swarm/models/container.rb

Overview

Represents a Docker Container

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DockerSwarm::Concerns::Loggable

#logs

Methods included from DockerSwarm::Concerns::Deletable

#destroy

Methods included from DockerSwarm::Concerns::Creatable

#query_params_for_docker, #save

Methods inherited from Base

all, #as_json, #assign_attributes, #attributes, defined_attributes, find, #id, #initialize, #method_missing, #payload_for_docker, #persisted?, #reload, resource_name, #respond_to_missing?, root_key, routes, #serializable_hash, where

Methods included from DockerSwarm::Concerns::Inspectable

#inspect

Constructor Details

This class inherits a constructor from DockerSwarm::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DockerSwarm::Base

Class Method Details

.create_query_paramsArray<String>

POST /containers/create toma el nombre por query string. En el body Docker lo descarta en silencio y responde 201: el container nace con nombre aleatorio y la adopción por nombre determinista en un reintento no encuentra nada, así que el reintento duplica. Ver ADR-025 cláusula 1.

Returns:

  • (Array<String>)


16
17
18
# File 'lib/docker_swarm/models/container.rb', line 16

def self.create_query_params
  %w[name].freeze
end

Instance Method Details

#startBoolean

Starts the container

Returns:

  • (Boolean)

    true if successful



22
23
24
25
# File 'lib/docker_swarm/models/container.rb', line 22

def start
  Api.request(action: self.class.routes[:start], arguments: { id: self.ID })
  true
end

#stopBoolean

Stops the container

Returns:

  • (Boolean)

    true if successful



29
30
31
32
# File 'lib/docker_swarm/models/container.rb', line 29

def stop
  Api.request(action: self.class.routes[:stop], arguments: { id: self.ID })
  true
end