The very personal dotfiles of Levi Olson.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
699 B

#!/bin/bash
##########################################
# docker-cleanup-everything
# ------------
# Based on the amazing work of Jess Frazelle
#
# Dependencies: docker
#
# :author: Levi Olson
# :date: 31 Jan 2018
# :version: 0.0.1
##########################################
cleanup() {
local containers
mapfile -t containers < <(docker ps -aq 2>/dev/null)
docker rm "${containers[@]}" 2>/dev/null
local volumes
mapfile -t volumes < <(docker ps --filter status=exited -q 2>/dev/null)
docker rm -v "${volumes[@]}" 2>/dev/null
local images
mapfile -t images < <(docker images --filter dangling=true -q 2>/dev/null)
docker rmi "${images[@]}" 2>/dev/null
}
cleanup