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`
This commit is contained in:
jansorg 2018-11-15 10:50:37 +01:00 committed by Grégoire Henry
parent 2cd1be9ee9
commit d4864216b4
No known key found for this signature in database
GPG Key ID: 50D984F20BD445D2

View File

@ -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() {