#!/bin/bash

if [ -n "$1" ]; then
    containers_to_stop=($(docker ps | grep -E "$1" | awk '{print $1}'))
else
    containers_to_stop=$(docker ps --filter "label=kolla_version" --format "{{.Names}}" -a)
fi

echo "Stopping containers..."
(docker stop -t 30 ${containers_to_stop} 2>&1) > /dev/null

echo "All containers stopped!"
