Docker Community Forums

Share and learn in the Docker community.

Getting the local ethwe1 IP address of a linked service?


(Derek Donnelly) #1

What’s the best way to get the local ethwe1 IP address of a linked service in a bash script running in a container in docker cloud?

environment:
    - CLUSTER=servicecontainer-1

In a .sh script running

CLUSTER_IP=$(getent hosts $CLUSTER | awk '{print $1}' | tail -1)
echo "CLUSTER_IP $CLUSTER_IP"

The above works with tail. Without tail I get both the eth0 and ethwe1 interfaces ips.

Is there a cleaner way?