Skip to content

Commit 76b759d

Browse files
committed
Fix docker logs error when no containers found
Check if containers exist before trying to show logs. This prevents 'docker logs requires 1 argument' error when a container fails to start and no matching containers are found.
1 parent 9f3fe4a commit 76b759d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/tidb-test-cluster.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ function destroy_cluster() {
102102
}
103103

104104
function show_docker_logs_and_exit() {
105-
docker ps -a -q -f name=$1 |xargs docker logs --details 2>&1
105+
CONTAINERS=$(docker ps -a -q -f name=$1)
106+
if [ ! -z "$CONTAINERS" ]; then
107+
echo "$CONTAINERS" | xargs docker logs --details 2>&1
108+
fi
106109
echo "Error with $1 component. For debugging use:"
107110
echo "docker ps -a -q -f name=$1 |xargs docker logs"
108111
exit 1

0 commit comments

Comments
 (0)