Class: Coursemology::Evaluator::DockerContainer
- Inherits:
-
Docker::Container
- Object
- Docker::Container
- Coursemology::Evaluator::DockerContainer
- Defined in:
- lib/coursemology/evaluator/docker_container.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
-
#exit_code ⇒ Fixnum?
Gets the exit code of the container.
-
#wait(time = nil) ⇒ Fixnum
Waits for the container to exit the Running state.
Class Method Details
.create(image, argv: nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/coursemology/evaluator/docker_container.rb', line 4 def create(image, argv: nil) pull_image(image) ActiveSupport::Notifications.instrument('create.docker.evaluator.coursemology', image: image) do |payload| = { 'Image' => image } ['Cmd'] = argv if argv && !argv.empty? payload[:container] = super() end end |
Instance Method Details
#delete ⇒ Object
73 74 75 76 77 78 |
# File 'lib/coursemology/evaluator/docker_container.rb', line 73 def delete ActiveSupport::Notifications.instrument('destroy.docker.evaluator.coursemology', container: id) do super end end |
#exit_code ⇒ Fixnum?
Gets the exit code of the container.
69 70 71 |
# File 'lib/coursemology/evaluator/docker_container.rb', line 69 def exit_code info.fetch('State', {})['ExitCode'] end |
#wait(time = nil) ⇒ Fixnum
Waits for the container to exit the Running state.
This will time out for long running operations, so keep retrying until we return.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/coursemology/evaluator/docker_container.rb', line 52 def wait(time = nil) container_state = info while container_state.fetch('State', {}).fetch('Running', true) super refresh! container_state = info end container_state['State']['ExitCode'] rescue Docker::Error::TimeoutError retry end |