class Dockit::Image
Attributes
image[R]
Public Class Methods
clean(force: false, except: [])
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/dockit/image.rb, line 34 def get(name) Docker::Image.get(name) end
list(all: false, filters: nil)
click to toggle source
# File lib/dockit/image.rb, line 6 def list(all: false, filters: nil) Docker::Image.all(all: all, filters: JSON.dump(filters)) end
Private Class Methods
convert_buildargs(config)
click to toggle source
# File lib/dockit/image.rb, line 57 def convert_buildargs(config) return unless args = config['buildargs'] return if args.is_a?(String) config['buildargs'] = args.to_json end