From d4864216b473ab30737e2b64d4908603b322d370 Mon Sep 17 00:00:00 2001 From: jansorg Date: Thu, 15 Nov 2018 10:50:37 +0100 Subject: [PATCH] Script: retrieve the name of the container from 'docker ps' (closes #392) This is required to work with the random suffix added by `docker-compose.1.23` --- scripts/alphanet.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh index 61ad1b621..95a7a1503 100755 --- a/scripts/alphanet.sh +++ b/scripts/alphanet.sh @@ -133,7 +133,7 @@ exec_docker() { container_args+=("${arg}"); fi done - docker exec "$interactive_flags" "$docker_node_container" "${container_args[@]}" + docker exec "$interactive_flags" "$(container_name "$docker_node_container")" "${container_args[@]}" } ## Container ############################################################### @@ -170,7 +170,7 @@ may_pull_image() { uptodate_container() { running_image=$(docker inspect \ --format="{{ .Image }}" \ - --type=container "$1") + --type=container "$(container_name "$1")") latest_image=$(docker inspect \ --format="{{ .Id }}" \ --type=image "$docker_image") @@ -189,6 +189,10 @@ assert_container() { call_docker_compose up --no-start } +container_name() { + docker ps --filter "name=$1" --format "{{.Names}}" +} + ## Node #################################################################### check_node_volume() { @@ -211,9 +215,8 @@ clear_node_volume() { check_node() { res=$(docker inspect \ --format="{{ .State.Running }}" \ - --type=container "$docker_node_container" 2>/dev/null \ - || echo false) - [ "$res" = true ] + --type=container "$(container_name "$docker_node_container")" 2>/dev/null) + [ -n "$res" ] } assert_node() { @@ -284,8 +287,8 @@ check_baker() { docker_baker_containers="$(sed "s/^\(.*\)$/${docker_compose_name}_baker-\1_1/g" "$active_protocol_versions")" res=$(docker inspect \ --format="{{ .State.Running }}" \ - --type=container $docker_baker_containers 2>/dev/null | grep false) - [ -z "$res" ] + --type=container "$(container_name "$docker_baker_containers")" 2>/dev/null) + [ -n "$res" ] } assert_baker() { @@ -349,8 +352,8 @@ check_endorser() { docker_endorser_containers="$(sed "s/^\(.*\)$/${docker_compose_name}_endorser-\1_1/g" "$active_protocol_versions")" res=$(docker inspect \ --format="{{ .State.Running }}" \ - --type=container $docker_endorser_containers 2>/dev/null | grep false) - [ -z "$res" ] + --type=container "$(container_name "$docker_endorser_containers")" 2>/dev/null) + [ -n "$res" ] } assert_endorser() { @@ -414,8 +417,8 @@ check_accuser() { docker_accuser_containers="$(sed "s/^\(.*\)$/${docker_compose_name}_accuser-\1_1/g" "$active_protocol_versions")" res=$(docker inspect \ --format="{{ .State.Running }}" \ - --type=container $docker_accuser_containers 2>/dev/null | grep false) - [ -z "$res" ] + --type=container "$(container_name "$docker_accuser_containers")" 2>/dev/null) + [ -n "$res" ] } assert_accuser() {