From 125ae1e82704b24a1a620f7fc783a2b29b75737c Mon Sep 17 00:00:00 2001 From: Michael Sauter Date: Fri, 8 Mar 2024 11:07:31 +0100 Subject: [PATCH] Use docker container inspect docker inspect may also return image information, which is not desired. --- scripts/kind-with-registry.sh | 8 ++++---- scripts/run-bitbucket.sh | 2 +- scripts/run-nexus.sh | 2 +- scripts/run-sonarqube.sh | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/kind-with-registry.sh b/scripts/kind-with-registry.sh index ac8f7575..5940afad 100755 --- a/scripts/kind-with-registry.sh +++ b/scripts/kind-with-registry.sh @@ -55,12 +55,12 @@ reg_ip_selector='{{.NetworkSettings.Networks.kind.IPAddress}}' reg_network='kind' # create registry container unless it already exists -running="$(docker inspect -f '{{.State.Running}}' "${registry_name}" 2>/dev/null || true)" +running="$(docker container inspect -f '{{.State.Running}}' "${registry_name}" 2>/dev/null || true)" # If the registry already exists, but is in the wrong network, we have to # re-create it. if [ "${running}" = 'true' ]; then - reg_ip="$(docker inspect -f ${reg_ip_selector} "${registry_name}")" + reg_ip="$(docker container inspect -f ${reg_ip_selector} "${registry_name}")" if [ "${reg_ip}" = '' ]; then docker kill "${registry_name}" docker rm "${registry_name}" @@ -73,7 +73,7 @@ if [ "${running}" != 'true' ]; then if [ "${net_driver}" != "bridge" ]; then docker network create "${reg_network}" fi - if docker inspect "${registry_name}" >/dev/null 2>&1; then + if docker container inspect "${registry_name}" >/dev/null 2>&1; then docker rm "${registry_name}" fi docker run \ @@ -81,7 +81,7 @@ if [ "${running}" != 'true' ]; then registry:2 fi -reg_ip="$(docker inspect -f ${reg_ip_selector} "${registry_name}")" +reg_ip="$(docker container inspect -f ${reg_ip_selector} "${registry_name}")" if [ "${reg_ip}" = "" ]; then echo "Error creating registry: no IPAddress found at: ${reg_ip_selector}" exit 1 diff --git a/scripts/run-bitbucket.sh b/scripts/run-bitbucket.sh index 5652d276..b1166ad6 100755 --- a/scripts/run-bitbucket.sh +++ b/scripts/run-bitbucket.sh @@ -29,7 +29,7 @@ while [ "$#" -gt 0 ]; do esac; shift; done if [ "${reuse}" = "true" ]; then - if ! docker inspect ${BITBUCKET_SERVER_CONTAINER_NAME} &> /dev/null; then + if ! docker container inspect ${BITBUCKET_SERVER_CONTAINER_NAME} &> /dev/null; then echo "No existing Bitbucket container ${BITBUCKET_SERVER_CONTAINER_NAME} found ..." else echo "Reusing existing Bitbucket container ${BITBUCKET_SERVER_CONTAINER_NAME} ..." diff --git a/scripts/run-nexus.sh b/scripts/run-nexus.sh index 1232e00a..59270daa 100755 --- a/scripts/run-nexus.sh +++ b/scripts/run-nexus.sh @@ -33,7 +33,7 @@ while [ "$#" -gt 0 ]; do esac; shift; done if [ "${reuse}" = "true" ]; then - if ! docker inspect ${CONTAINER_NAME} &> /dev/null; then + if ! docker container inspect ${CONTAINER_NAME} &> /dev/null; then echo "No existing Nexus container ${CONTAINER_NAME} found ..." else echo "Reusing existing Nexus container ${CONTAINER_NAME} ..." diff --git a/scripts/run-sonarqube.sh b/scripts/run-sonarqube.sh index f833d7a5..cc81d841 100755 --- a/scripts/run-sonarqube.sh +++ b/scripts/run-sonarqube.sh @@ -30,7 +30,7 @@ while [ "$#" -gt 0 ]; do esac; shift; done if [ "${reuse}" = "true" ]; then - if [ "$(docker inspect ${CONTAINER_NAME} -f '{{.State.Running}}')" = "true" ]; then + if [ "$(docker container inspect ${CONTAINER_NAME} -f '{{.State.Running}}')" = "true" ]; then echo "Reusing running SonarQube container ${CONTAINER_NAME} ..." exit 0 else