From ce288a4e9fce28a9a55e689f74628cf1b44c299a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Piotrowski?= Date: Mon, 5 Oct 2015 13:00:45 +0200 Subject: [PATCH] Fix few small issues with dockerctl inspect * display inspect usage if no arguments were given * iterate over given containers to show concatenated output * print error message if one of many containers doesn't exist Change-Id: Idfa3f3db01a5287d4970772b250f085ce890134e Closes-bug: 1400776 --- files/fuel-docker-utils/dockerctl | 5 +++-- files/fuel-docker-utils/functions.sh | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/files/fuel-docker-utils/dockerctl b/files/fuel-docker-utils/dockerctl index e8115ae665..063474bbaf 100644 --- a/files/fuel-docker-utils/dockerctl +++ b/files/fuel-docker-utils/dockerctl @@ -96,7 +96,7 @@ case "$1" in shift $cmd "$@" ;; logs|inspect) - if [[ $container == 'all' ]]; then + if [[ $2 == 'all' ]]; then echo "You need to specify valid container name." echo "Use 'dockerctl list' to see available containers." @@ -104,7 +104,8 @@ case "$1" in fi cmd=$1 - $cmd $container ;; + shift + $cmd "$@" ;; *) echo 'Invalid selection.' show_usage diff --git a/files/fuel-docker-utils/functions.sh b/files/fuel-docker-utils/functions.sh index 6f42df8062..b21404ee9a 100644 --- a/files/fuel-docker-utils/functions.sh +++ b/files/fuel-docker-utils/functions.sh @@ -372,7 +372,21 @@ function logs { } function inspect { - ${DOCKER} inspect ${CONTAINER_NAMES[$1]} + for container in $@; do + found="$(docker ps -a -q --filter="name=${CONTAINER_NAMES[$container]}" | wc -l)" + + if [[ $? -ne 0 || $found -ne 1 ]]; then + echo "Could not find the $container container" 1>&2 + + if [[ $# -le 1 ]]; then + docker inspect + else + continue + fi + fi + + ${DOCKER} inspect ${CONTAINER_NAMES[$container]} + done } function restart_container {