Skip to content

Instantly share code, notes, and snippets.

@tywkeene
Last active Aug 29, 2015
Embed
What would you like to do?
A simple command line tool to nuke your docker
#!/usr/bin/env ruby
require 'docker'
actions = {
"rmi" => lambda{|force|
Docker::Image.all.map{|img|
puts img.id[0..12]
img.remove(:force => force)}
},
"rm" => lambda{|force|
Docker::Container.all(:all => true).map{|cont|
puts cont.id[0..12]
cont.delete(:force => force)}
}
}
if ARGV[0].nil? or !ARGV[1].nil? and ARGV[1] != '-f'
puts "Usage: #{__FILE__} <rm -f> <rmi -f> \n"\
"\trm - Remove all containers\n"\
"\trmi - Remove all images\n"\
"\t-f - Force deletion\n"
exit
end
force = (ARGV[1] == '-f') ? true : false
actions[ARGV[0]].call(force)
@tywkeene
Copy link
Author

tywkeene commented Nov 14, 2014

Be sure to chmod +x and put it in your ~/bin for the best nuking experience

requires the gem docker-api to run (https://github.com/swipely/docker-api)

gem install docker-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment