diff --git a/load_docker_images.sh b/load_docker_images.sh index fd14c550937313ee80543aefa8e7e522b2ca4c26..e41bae7a7b2e97f1abdfb6cc550050cb41ca9e7e 100755 --- a/load_docker_images.sh +++ b/load_docker_images.sh @@ -38,9 +38,9 @@ start_docker() { echo "Starting Neo4j container..." echo "--------------------------------------------------------------------------" # Run Neo4j in detached mode (-d) - docker run -d --publish=7474:7474 --publish=7687:7687 --volume=$HOME/neo4j/data:/data --name neo4j-container --rm --env NEO4J_AUTH=neo4j/secret_secret gitlab-registry.isae-supaero.fr/nanostar/nanospace/nanospace-docker-images:neo4j + docker run -d --publish=7474:7474 --publish=7687:7687 --volume=$HOME/neo4j/data:/data --name neo4j --rm --env NEO4J_AUTH=neo4j/secret_secret gitlab-registry.isae-supaero.fr/nanostar/nanospace/nanospace-docker-images:neo4j # Wait until the Neo4j container is running - wait_for_container "neo4j-container" + wait_for_container "neo4j" echo "Neo4j container started at http://localhost:7474/browser/." # Mosquitto service @@ -77,7 +77,6 @@ start_docker() { wait_for_container "nanospace-front-end-container" echo "Nanospace Front-end container started at http://localhost." - } #======================================================================================================== @@ -104,9 +103,11 @@ stop_docker() { echo "Stopping Docker services..." echo "--------------------------------------------------------------------------" + docker ps + # Stop the services only if they exist - stop_if_image_exists "neo4j" - stop_if_image_exists "eclipse-mosquitto" + stop_if_image_exists "gitlab-registry.isae-supaero.fr/nanostar/nanospace/nanospace-docker-images:neo4j" + stop_if_image_exists "gitlab-registry.isae-supaero.fr/nanostar/nanospace/nanospace-docker-images:eclipse-mosquitto" stop_if_image_exists "gitlab-registry.isae-supaero.fr/nanostar/nanospace/nanospace-front-end" stop_if_image_exists "gitlab-registry.isae-supaero.fr/nanostar/nanospace/nanospace-back-end" @@ -119,12 +120,14 @@ stop_docker() { # Function to stop a container if the image exists stop_if_image_exists() { local container_name=$1 - - if [ "$(docker ps -q -f name=^/${container_name}$)" ]; then - echo "'${container_name}' is running. Stopping..." - docker stop "${container_name}" + + container_id=$(docker ps -q -f ancestor=${container_name}) + + if [ -n "$container_id" ]; then + echo "${container_name} is running. Stopping..." + docker stop "${container_id}" else - echo "'${container_name}' not running." + echo "${container_name} is not running." fi } @@ -190,4 +193,3 @@ case "$1" in exit 1 ;; esac -