Module: Dockdev
- Defined in:
- lib/dockdev.rb,
lib/dockdev/image.rb,
lib/dockdev/version.rb,
lib/dockdev/container.rb,
lib/dockdev/workspace.rb
Defined Under Namespace
Classes: Container, Error, Image, Workspace
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
- .destroy(contName, opts = {}) ⇒ Object
-
.with_running_container(contName, opts = {}) ⇒ Object
Your code goes here…
Class Method Details
.destroy(contName, opts = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dockdev.rb', line 45 def self.destroy(contName, opts = {}) cont = Container.new(contName) if cont.has_container? cont.stop if cont.running? cont.destroy end img = Image.new(contName) if img.has_image? img.destroy end end |
.with_running_container(contName, opts = {}) ⇒ Object
Your code goes here…
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dockdev.rb', line 19 def self.with_running_container(contName, opts = {}) root = opts[:root] cmd = opts[:command] cont = Container.new(contName) if cont.has_container? if cont.running? cont.attach_and_exec(command: cmd) else cont.start_with_command(command: cmd) end else img = Image.new(contName) ws = opts[:workspace] || Dir.getwd wss = Workspace.new(ws) if img.has_image? img.new_container(cont.name, command: cmd) elsif wss.has_dockerfile? img.build(wss.dockerfile) img.new_container(cont.name, command: cmd) else raise Error, "\n No image and no Dockerfile found to build the image found. Operation aborted. \n\n".red end end end |