Docker Community Forums

Share and learn in the Docker community.

Container IP in docker-compose command

(Mvitale) #1


I’ve the need to put the IP address for a container in a command in
docker-compose. Like so:

    command: -advertise-client-urls=
#    command: -advertise-client-urls=http://$${ETCD_PORT_2379_TCP_ADDR}:2379
#    command: -advertise-client-urls=http://etcd:2379 -listen-client-urls= 
      - "2379:2379"
      - "/usr/share/ca-certificates/:/etc/ssl/certs"

I’d like to use something like the commented out versions, but they don’t
Using in -advertise-client-urls doesn’t allow to reach etcd from
other containers.
Hardcoding the IP address works, but is not a good solution.

Any suggestion?

(Mvitale) #2

Ok, since I’m getting no answers, I ended up running a shell wrapper that gets the IP using $(hostname -i)
The shell wrapper is then controlled by supervisord. I don’t like that I cannot directly send signals to etcd this way.

But there really should be a docker-compose way. If there’s one and I’ve missed it, I’m still interested in learning what it is.

(Jamshid) #3

I don’t know if there’s a better way, but if you want to get rid of supervisord and have signals forwarded, maybe you can use