#!/bin/sh

containers=$(docker ps | grep '\([3-9][0-9] minutes\|hour\|day\)')

if [ -n "$containers" ]; then
    docker ps | grep '\([3-9][0-9] minutes\|hour\|day\)' | awk '{print $1}' | xargs docker kill
fi

#!/bin/sh

containers=$(sudo docker ps -a | grep '\([3-9][0-9] minutes\|hour\|day\|Exit\)')

if [ -n "$containers" ]; then
    sudo docker ps -a | grep '\([3-9][0-9] minutes\|hour\|day\|Exit\)' | awk '{print $1}' | xargs sudo docker kill
    sudo docker ps -a | grep '\([3-9][0-9] minutes\|hour\|day\|Exit\)' | awk '{print $1}' | xargs sudo docker rm
fi

Kill containers now removes exited containers
Kill containers now removes exited containers
