github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/deploy/dev/docker/get_ip_addresses.sh (about)

     1  #!/bin/bash
     2  
     3  # The following script lists the public, internal and replication network IP
     4  # Addresses for each daemon.
     5  SETUP_FILE="/tmp/docker_ais/deploy.env"
     6  if [ -f $"$SETUP_FILE" ]; then
     7      # get $PORT, $PORT_INTRA_CONTROL and $PORT_INTRA_DATA
     8      source $SETUP_FILE
     9  fi
    10  
    11  for container_name in $(docker ps --format "{{.Names}}"); do
    12      connected_networks=$(docker inspect -f '{{range $key, $value := .NetworkSettings.Networks}}{{printf "%s " $key}}{{end}}' $container_name)
    13      echo $container_name
    14      for network in $connected_networks
    15      do
    16          if [[ $network =~ ^${container_name:0:5} ]]
    17          then
    18              format="'{{.NetworkSettings.Networks.${network}.IPAddress}}'"
    19              ip_address=$(docker inspect -f $format $container_name)
    20              ip_address=${ip_address//\'/}   # remove all single quotes
    21              if [[ "$network" == *"public"* ]]; then
    22                  echo "    $network: $ip_address:${PORT:-51080}"
    23              elif [[ "$network" == *"internal_control"* ]]; then
    24                  echo "    $network: $ip_address:${PORT_INTRA_CONTROL:-9080}"
    25              else
    26                  echo "    $network: $ip_address:${PORT_INTRA_DATA:-10080}"
    27              fi
    28          fi
    29      done
    30      echo
    31  done
    32  
    33  echo "Note if the docker deploy script was called from a different terminal window, the correct port numbers might not be listed above."
    34