Docker Community Forums

Share and learn in the Docker community.

Container with multiple networks on Docker Swarm

swarm

#1

Hello Captains!

I tried to setup zalando/patroni on a docker swarm. I have all ready a consul cluster up on a different stack with an external Network and tried to use it.

My main problem is, i have now 2 IP-Addresses in each Container. I was not able to get always
the right one. Here is the Part from my entrypoint.sh:

DOCKER_IP=$(hostname -I|awk '{print $1}')
export PATRONI_CONSUL_HOST="${PATRONI_CONSUL_HOST:-${DOCKER_IP}:8500}"
export PATRONI_NAME="${PATRONI_NAME:-${HOSTNAME}}"
export PATRONI_RESTAPI_CONNECT_ADDRESS="${DOCKER_IP}:8008"
export PATRONI_RESTAPI_LISTEN="0.0.0.0:8008"
export PATRONI_POSTGRESQL_CONNECT_ADDRESS="${DOCKER_IP}:5432"

Sometimes it gets the right address sometimes the one from the consul Network. What would you recommend?

Thanks
Tim