gliderlabs / registrator

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

Why the service name is not exactly what I set ? #501

Closed eromoe closed 7 years ago

eromoe commented 7 years ago

Description of the problem:

I start two nginx with -e "SERVICE_NAME=n1" and -e "SERVICE_NAME=n2" , but what I got in consul api is n1-80 and n2-80, why it append =80?? I don't want that.

Steps to Reproduce:

  1. start consul
    docker run -d \
     -p 8500:8500 \
     -p 8600:53/udp \
     --name consul \
     progrium/consul \
     -server \
     -bootstrap \
     -log-level debug
  2. start registrator
    docker run -d \
        --name=registrator \
        --net=host \
        --volume=/var/run/docker.sock:/tmp/docker.sock \
        gliderlabs/registrator:latest \
          consul://localhost:8500
  3. start two nginx with name n1 and n2

    docker run -d \
    -e "SERVICE_NAME=n1" \
    -e "SERVICE_TAGS=master,backups" \
    -e "SERVICE_REGION=fujian_2" \
    -p 8001:80 \
    --name n1 \
    nginx
    
    docker run -d \
    -e "SERVICE_NAME=n2" \
    -e "SERVICE_TAGS=master,backups" \
    -e "SERVICE_REGION=fujian_2" \
    -p 8002:80 \
    --name n2 \
    nginx

Actual Results:

curl localhost:8500/v1/catalog/services?pretty
{
    "consul": [],
    "consul-53": [
        "udp"
    ],
    "consul-8500": [],
    "n1-80": [
        "master",
        "backups"
    ],
    "n2-80": [
        "master",
        "backups"
    ]
}

Expected Results:

curl localhost:8500/v1/catalog/services?pretty
{
    "consul": [],
    "consul-53": [
        "udp"
    ],
    "consul-8500": [],
    "n1": [
        "master",
        "backups"
    ],
    "n2": [
        "master",
        "backups"
    ]
}
jhmartin commented 7 years ago

See https://github.com/gliderlabs/registrator/pull/473