Class: Dockit::Image
- Inherits:
-
Object
- Object
- Dockit::Image
- Defined in:
- lib/dockit/image.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Class Method Summary collapse
- .clean(force: false, except: []) ⇒ Object
- .create(config) ⇒ Object
- .get(name) ⇒ Object
- .list(all: false, filters: nil) ⇒ Object
Instance Attribute Details
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/dockit/image.rb', line 3 def image @image end |
Class Method Details
.clean(force: false, except: []) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dockit/image.rb', line 38 def clean(force: false, except: []) except ||= [] puts "Images..." list( all: force, filters: force ? nil : {dangling: ['true']} ).each do |image| names = image.info["RepoTags"]||[] puts " #{image.id}" if (names & except).count > 0 puts " ... skipping #{names}" next end image.remove(force: true) end end |
.create(config) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dockit/image.rb', line 10 def create(config) unless config STDERR.puts "No build target configured" return end repos = config['t'] puts "Building #{repos}" convert_buildargs(config) begin image = Docker::Image.build_from_dir('.', config) do |chunk| Dockit::Log.print_chunk(chunk) end rescue Docker::Error::TimeoutError => e $stderr.puts '* Read timeout, try again with a larger "--timeout"' exit 1 rescue Docker::Error::UnexpectedResponseError => e $stderr.puts 'Build error, exiting.' exit 1 end image end |
.get(name) ⇒ Object
34 35 36 |
# File 'lib/dockit/image.rb', line 34 def get(name) Docker::Image.get(name) end |
.list(all: false, filters: nil) ⇒ Object
6 7 8 |
# File 'lib/dockit/image.rb', line 6 def list(all: false, filters: nil) Docker::Image.all(all: all, filters: JSON.dump(filters)) end |