gliderlabs / registrator

Service registry bridge for Docker with pluggable adapters
http://gliderlabs.com/registrator
MIT License
4.66k stars 913 forks source link

Wrong IP after switching to docker-compose v2 #386

Open vintikzzz opened 8 years ago

vintikzzz commented 8 years ago

After switching to docker-copmose v2 all containers starts to register with consul IP address. All details are available in a gist

neoshadybeat commented 8 years ago

me too

vintikzzz commented 8 years ago

I've solved this issue. The only thing that must to be done is - to rebuild image.

How to check:

  1. Clone registrator to local machine
  2. Make docker-compose.yml inside registrator folder:
version: '2'
services:
  consul:
    command: -server -bootstrap
    image: progrium/consul
    ports:
      - "8300:8300"
      - "8400:8400"
      - "8500:8500"
      - "8600:53/udp"

  registrator:
    command: -internal consul://consul:8500
    build:
      context: .
      dockerfile: ./Dockerfile
    depends_on:
      - consul
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock

  app:
    image: buildpack-deps:jessie-curl
    command: /bin/sh -c 'while true; do sleep 1; done'
    expose:
      - 3000
    depends_on:
      - registrator
  1. Build this with docker-compose build
  2. Run app container with docker-compose run bash
  3. Run few curl requests to find out consul data for app container
root@57decafee46f:/# curl http://consul:8500/v1/catalog/services
{"alpine":[],"buildpack-deps":[],"capybara-webkit-server":[],"consul":[],"consul-53":["udp"],"consul-8300":[],"consul-8301":["udp"],"consul-8302":["udp"],"consul-8400":[],"consul-8500":[]}root@57decafee46f:/# curl http://consul:8500/v1/catalog/service/buildpack-deps
[{"Node":"c059dfd257a9","Address":"172.20.0.2","ServiceID":"521e4ee1ab77:registrator_app_run_8:3000","ServiceName":"buildpack-deps","ServiceTags":null,"ServiceAddress":"172.20.0.5","ServicePort":3000}]root@57decafee46f:/# 

As we can see, ServiceAddress field become availabe!

Please rebuild image!