Docker Community Forums

Share and learn in the Docker community.

Container IP in docker-compose command


(Mvitale) #1

G’day,

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

  etcd:
    image: quay.io/coreos/etcd:v2.3.0-alpha.1
    command: -advertise-client-urls=http://172.17.0.6:2379
-listen-client-urls=http://0.0.0.0:2379 
#    command: -advertise-client-urls=http://$${ETCD_PORT_2379_TCP_ADDR}:2379
-listen-client-urls=http://0.0.0.0:2379 
#    command: -advertise-client-urls=http://etcd:2379 -listen-client-urls=
http://0.0.0.0:2379 
    ports:
      - "2379:2379"
    volumes:
      - "/usr/share/ca-certificates/:/etc/ssl/certs"

I’d like to use something like the commented out versions, but they don’t
work.
Using 0.0.0.0 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?
Thanks,


(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 https://github.com/Yelp/dumb-init.