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
551 B

#!/bin/bash
##########################################
# docker-cleanup-non-running-images
# ------------
# Based on the amazing work of Jess Frazelle
#
# Dependencies: docker
#
# :author: Levi Olson
# :date: 31 Jan 2018
# :version: 0.0.1
##########################################
set -e
set -o pipefail
cleanup() {
mapfile -t images < <(docker images -q --no-trunc)
for c in $(docker ps -aq); do
image=$(docker inspect --format '{{.Image}}' "$c")
images=( "${images[@]/$image}" )
done
docker rmi -f "${images[@]}" 2>&1 || true
}
cleanup