registrator icon indicating copy to clipboard operation
registrator copied to clipboard

exit at start with connection refused error

Open piotr-s-brainhub opened this issue 8 years ago • 7 comments

  • What version of docker are you running? 1.12.3
  • What version of registrator are you running? latest
  • Did you build a custom version of registrator? If so, what is that image? no
  • What is the exact command you are running registrator with?
docker run -d \
    --name=registrator \
    --net=host \
    --volume=/var/run/docker.sock:/tmp/docker.sock \
    gliderlabs/registrator:latest \
      consul://localhost:8500

(like in README)

  • What is the exact command you are running your container with? as above
  • A log capture of all the docker events before, during, and after the issue.
2016/12/05 20:05:12 Starting registrator v7 ...
2016/12/05 20:05:12 Using consul adapter: consul://localhost:8500
2016/12/05 20:05:12 Connecting to backend (0/0)
2016/12/05 20:05:12 Get http://localhost:8500/v1/status/leader: dial tcp 127.0.0.1:8500: connection refused

Description of the problem: the container exits at start

How reproducible: running command described in README

piotr-s-brainhub avatar Dec 05 '16 20:12 piotr-s-brainhub

maybe it's stating the obvious, but is consul running?

wliao008 avatar Dec 19 '16 15:12 wliao008

Have you tried replacing localhost with 127.0.0.1? I'm running on MacOSX and I had to do that

mengesb avatar Feb 22 '17 00:02 mengesb

With

docker run -d \
      --name=registrator \
      --net=host \
      --volume=/var/run/docker.sock:/tmp/docker.sock \
      gliderlabs/registrator:latest \
        consul://127.0.0.1:8500

I obtain:

2017/02/22 08:30:48 Starting registrator v7 ...
2017/02/22 08:30:48 Using consul adapter: consul://127.0.0.1:8500
2017/02/22 08:30:48 Connecting to backend (0/0)
2017/02/22 08:30:48 Get http://127.0.0.1:8500/v1/status/leader: dial tcp 127.0.0.1:8500: connection refused

Previously I was using Linux, now I'm using Mac.

piotr-s-brainhub avatar Feb 22 '17 08:02 piotr-s-brainhub

Having this issue too - tried running the consul server via brew, then the docker image directly since it wasn't working; neither works and I get the same err as the OP.

doing curl http://127.0.0.1:8500/v1/status/leader works from the cli (returns "127.0.0.1:8300")

theogravity avatar Jun 26 '17 07:06 theogravity

I think the issue is related to https://github.com/docker/compose/issues/3800

theogravity avatar Jun 26 '17 08:06 theogravity

Figured it out thanks to the comment:

https://github.com/docker/compose/issues/3800#issuecomment-236963975

You must use the new "Docker on Mac" app. I'm using the edge version (unsure if non-edge works).

Here's my setup (can most likely be combined into docker-compose.yml):

# Consul container
# 192.168.65.1 is the magic exposed IP
# that communicates back to the host / native
# https://github.com/moby/moby/issues/22753#issuecomment-282725489
# - UI can be accessed via http://127.0.0.1:8500/ui (not localhost)
# The consul agent (aka client / node) name is "local-dev-node"

# to stop the daemon, use "docker kill consul && docker rm consul"

docker run -d --name=consul \
	-p 8400:8400 \
	-p 8500:8500 \
	-p 8600:53/udp \
	-h local-dev-node progrium/consul \
	-server \
	-advertise 192.168.65.1 \
	-bootstrap \
	-ui-dir /ui

# After this runs, you should see the node in the consul ui
docker run -d \
    --name=registrator \
    --volume=/var/run/docker.sock:/tmp/docker.sock \
    gliderlabs/registrator:latest \
      -ip 192.168.65.1 \
      consul://192.168.65.1:8500

theogravity avatar Jun 26 '17 10:06 theogravity

There used to be a bunch macOS Docker network kludges, and there still are. But today, the simplest workaround is to just use consul://host.docker.internal:8500 for the registry URI. There is no need for a containerized consul, or explicitly advertising on magic IPs.

~Conversely, --net=host then becomes superfluous on Docker for Mac / Docker Desktop for Mac.~ You might still want --net=host, because otherwise registrator will prefix service instances with its hostname, and unless you override that with --hostname, it will just be a random container ID meaning each time registrator restarts it will register new (duplicated) instances for each service.

cbrunnkvist avatar Sep 09 '20 08:09 cbrunnkvist