I have Consul and a bunch of services on my local machine. Now I want to implement service registration in Consul using Registrator. If I do it like so:
$ docker run -d --name registrator --net=host \
--volume /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator \
consul://127.0.0.1:8500
And after that run some services, I see that they are registered in Consul. If however I try to do it via docker-compose.yml (since I do not want to run the above command each time by hand):
version: '2'
services:
consul:
image: gliderlabs/consul-server:latest
command: "advertise=127.0.0.1 -server -bootstrap"
container_name: consul
hostname: 127.0.0.1
ports:
- "8500:8500"
registrator:
image: gliderlabs/registrator:latest
command: "consulL//127.0.0.1:8500"
container_name: registrator
hostname: 127.0.0.1
depends_on:
- consul
volumes:
- /var/run/docker.sock:/tmp/docker.sock
... other services that need to be registered
And run:
$ docker-compose up
then I see in the console this error message:
registrator | 2017/01/16 17:01:24 Get http://127.0.0.1:8500/v1/status/leader dial tcp 127.0.0.1:8500: connection refused
I guess, my problem is related to the fact, that I didn't specify --net=host
. But I do not know how can I do that. I hope, someone knows how to fix it.