Class: Docker::Container
Overview
Object that represents a Docker container, its information and operations.
Instance Method Summary collapse
-
#exit_code ⇒ Integer
Master process exit code.
-
#id ⇒ String
Unique SHA256 container hash.
-
#image ⇒ String
SHA256 hash of image the container is derived from.
- #kill ⇒ Object
-
#name ⇒ String
Human-readable name of container ()minus initial /).
-
#pid ⇒ Integer
Master process PID.
- #rm ⇒ Object
- #start ⇒ Object
-
#status ⇒ String
Running, exited, etc.
- #stop ⇒ Object
Methods inherited from Asset
#initialize, #inspect, #to_h, #to_s
Constructor Details
This class inherits a constructor from Docker::Asset
Instance Method Details
#exit_code ⇒ Integer
Returns master process exit code.
30 31 32 |
# File 'lib/docker/container.rb', line 30 def exit_code @json['State']['ExitCode'] end |
#id ⇒ String
Returns unique SHA256 container hash.
5 6 7 |
# File 'lib/docker/container.rb', line 5 def id @json['Id'] end |
#image ⇒ String
Returns SHA256 hash of image the container is derived from.
15 16 17 |
# File 'lib/docker/container.rb', line 15 def image @json['Image'] end |
#kill ⇒ Object
34 35 36 37 |
# File 'lib/docker/container.rb', line 34 def kill raise Error, "Disconnected from session" unless @session @session.kill(id) end |
#name ⇒ String
Returns human-readable name of container ()minus initial /).
10 11 12 |
# File 'lib/docker/container.rb', line 10 def name super.sub(/^\//, '') end |
#pid ⇒ Integer
Returns master process PID.
25 26 27 |
# File 'lib/docker/container.rb', line 25 def pid @json['State']['Pid'] end |
#rm ⇒ Object
39 40 41 42 |
# File 'lib/docker/container.rb', line 39 def rm raise Error, "Disconnected from session" unless @session @session.rm(id) end |
#start ⇒ Object
44 45 46 47 |
# File 'lib/docker/container.rb', line 44 def start raise Error, "Disconnected from session" unless @session @session.start(id) end |
#status ⇒ String
Returns running, exited, etc.
20 21 22 |
# File 'lib/docker/container.rb', line 20 def status @json['State']['Status'] end |
#stop ⇒ Object
49 50 51 52 |
# File 'lib/docker/container.rb', line 49 def stop raise Error, "Disconnected from session" unless @session @session.stop(id) end |