Produced by Araxis Merge on 12/14/2017 1:27:58 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | CUI-CPP-v2.3.2-source.zip\bin | delete_docker_images_etal.rb | Mon Nov 20 23:19:07 2017 UTC |
| 2 | CUI-CPP-v2.3.2-source.zip\bin | delete_docker_images_etal.rb | Thu Dec 14 14:52:35 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 304 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | #!/usr/bin /env ruby | |
| 2 | # encoding : utf-8 | |
| 3 | ########## ########## ########## ########## ########## ######## | |
| 4 | ### | |
| 5 | ## File: create_doc ker_images .rb | |
| 6 | ## Desc: Do that do cker thing | |
| 7 | ## By: PII | |
| 8 | # | |
| 9 | ||
| 10 | require 'a wesome_pri nt' | |
| 11 | ||
| 12 | require 'd ebug_me' | |
| 13 | include De bugMe | |
| 14 | ||
| 15 | require 'c li_helper' | |
| 16 | include Cl iHelper | |
| 17 | ||
| 18 | configatro n.version = '0.0.1' # The ver sion of th is program . | |
| 19 | ||
| 20 | require 'p athname' | |
| 21 | ||
| 22 | cli_helper ("\nDelete docker im ages and c ontainers" ) do |o| | |
| 23 | ||
| 24 | o.bool '- -delete-co ntainers', 'Delete Do cker Conta iners', defa ult: false | |
| 25 | o.bool '- -delete-im ages', 'Delete Do cker Image s', defa ult: false | |
| 26 | o.bool '- -all', 'Delete Al l Docker S tuff', defa ult: false | |
| 27 | ||
| 28 | end | |
| 29 | ||
| 30 | ||
| 31 | # Error ch eck your s tuff; use error('som e message' ) and warn ing('some message') | |
| 32 | ||
| 33 | ||
| 34 | ||
| 35 | abort_if_e rrors | |
| 36 | ||
| 37 | if configa tron.all | |
| 38 | configat ron.delete _images = true | |
| 39 | configat ron.delete _container s = true | |
| 40 | end | |
| 41 | ||
| 42 | ||
| 43 | ########## ########## ########## ########## ########## #### | |
| 44 | # Local me thods | |
| 45 | ||
| 46 | ||
| 47 | ||
| 48 | # exposes the comman d line par ameter val ue in an e asy to rea d form | |
| 49 | def delete _images? | |
| 50 | configat ron.delete _images | |
| 51 | end | |
| 52 | ||
| 53 | ||
| 54 | # exposes the comman d line par ameter val ue in an e asy to rea d form | |
| 55 | def delete _container s? | |
| 56 | configat ron.delete _container s | |
| 57 | end | |
| 58 | ||
| 59 | ||
| 60 | # outputs to STDOUT a banner t o head the section | |
| 61 | def sectio n_header(a _string) | |
| 62 | if verbo se? || d ebug? | |
| 63 | puts " \n\n" + "= "*45 | |
| 64 | puts " == #{a_str ing} ..." | |
| 65 | puts | |
| 66 | end | |
| 67 | end | |
| 68 | ||
| 69 | ########## ########## ########## ########## ########## #### | |
| 70 | # Main | |
| 71 | ||
| 72 | at_exit do | |
| 73 | puts | |
| 74 | puts "Do ne." | |
| 75 | puts | |
| 76 | end | |
| 77 | ||
| 78 | ap configa tron.to_h if debug? | |
| 79 | ||
| 80 | ||
| 81 | ########## ########## ########## ########## ########## ########## ########## ######## | |
| 82 | ## Delete Docker Con tainers | |
| 83 | ||
| 84 | if delete_ containers ? | |
| 85 | ||
| 86 | commands = [ | |
| 87 | "docke r stop $(d ocker ps - a -q)", | |
| 88 | "docke r rm $(doc ker ps -a -q)" | |
| 89 | ] | |
| 90 | ||
| 91 | containe rs = `dock er ps -a - q`.split(" \n") | |
| 92 | ||
| 93 | unless c ontainers. empty? | |
| 94 | ||
| 95 | sectio n_header " Stopping a nd removin g all dock er contain ers" | |
| 96 | ||
| 97 | comman ds.each do |command| | |
| 98 | puts ".. Execu ting: #{co mmand}" if verbose? || debug ? | |
| 99 | syst em command | |
| 100 | end | |
| 101 | ||
| 102 | end # un less conta iners.empt y? | |
| 103 | ||
| 104 | end # if d elete_cont ainers? | |
| 105 | ||
| 106 | ||
| 107 | ||
| 108 | ########## ########## ########## ########## ########## ########## ########## ######## | |
| 109 | ## Delete Existing d ocker imag es | |
| 110 | ||
| 111 | # SMELL: This secti on will de lete ALL d ocker imag es even th ose that a re not | |
| 112 | # associated with this applicati on | |
| 113 | ||
| 114 | if delete_ images? | |
| 115 | section_ header "De leting doc ker images " | |
| 116 | ||
| 117 | images = `docker i mages -q`. split("\n" ) | |
| 118 | ||
| 119 | unless i mages.empt y? | |
| 120 | ||
| 121 | messag e = <<~EOS | |
| 122 | ||
| 123 | All docker ima ges will b e deleted. All mean s ALL; not just the | |
| 124 | ones associate d with thi s applicat ion but AL L that you have defi ned | |
| 125 | on y our workst ation. | |
| 126 | ||
| 127 | Here is the re sult of a 'docker im ages' comm and: | |
| 128 | ||
| 129 | #{`d ocker imag es`} | |
| 130 | ||
| 131 | EOS | |
| 132 | ||
| 133 | warnin g message | |
| 134 | ||
| 135 | abort_ if_errors | |
| 136 | ||
| 137 | images .each do | image_id| | |
| 138 | comm and = "doc ker rmi #{ image_id} --force" | |
| 139 | puts "Executin g: #{comma nd} ..." i f verbose? || debu g? | |
| 140 | syst em command | |
| 141 | end | |
| 142 | end | |
| 143 | ||
| 144 | end # if d elete_imag es? | |
| 145 | ||
| 146 | ||
| 147 | if ARGV.em pty? | |
| 148 | puts | |
| 149 | command = "docker images" | |
| 150 | puts "Ex ecuting: # {command} ..." if ve rbose? || debug? | |
| 151 | system c ommand | |
| 152 | end | |
| 153 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.