gliderlabs / docker-consul

Dockerized Consul
MIT License
1.07k stars 286 forks source link

Consul service registration and DNS #75

Open peebles opened 9 years ago

peebles commented 9 years ago

First of all, if I run:

$ docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h consul --name=consul progrium/consul -server -bootstrap -ui-dir /ui $ curl http://$(docker-machine ip local):8500/v1/catalog/service/consul [{"Node":"consul","Address":"172.17.0.17","ServiceID":"consul","ServiceName":"consul","ServiceTags":[],"ServiceAddress":"","ServicePort":8300}]

Why is "ServiceAddress" blank?

Then, when I run one of my containers:

cat /etc/resolv.conf

nameserver 172.17.42.1 nameserver 8.8.8.8 search service.consul

But:

ping consul

ping: unknown host consul

I noticed in Dockerfile (master), its using docker 1.5. I am using 1.6. So I tried my own image build with 1.6 but I get the same results.

I can ping:

ping 172.17.42.1

PING 172.17.42.1 (172.17.42.1) 56(84) bytes of data. 64 bytes from 172.17.42.1: icmp_seq=1 ttl=64 time=0.144 ms

and when I use registrator and run another service, that service does resolve properly. So it seems that the consul container itself is the one having problems.

\ I am on OSX, using docker-machine.

peebles commented 9 years ago

Turns out that other services registered with registrator also do not resolve, I was wrong about that.

JohnyDays commented 9 years ago

Are you using an alpine-based container?

peebles commented 9 years ago

For registrater, yes:

FROM gliderlabs/alpine:3.1

ENTRYPOINT ["/bin/registrator"]

COPY . /go/src/github.com/gliderlabs/registrator

RUN apk-install -t build-deps go git mercurial \

&& cd /go/src/github.com/gliderlabs/registrator \

&& export GOPATH=/go \

&& go get \

&& go build -ldflags "-X main.Version $(cat VERSION)" -o /bin/registrator \

&& rm -rf /go \

&& apk del --purge build-deps

On Mon, Aug 31, 2015 at 3:30 AM, John Days notifications@github.com wrote:

Are you using an alpine-based container?

— Reply to this email directly or view it on GitHub https://github.com/gliderlabs/docker-consul/issues/75#issuecomment-136327279 .

JohnyDays commented 9 years ago

Hmm, if you were using it for other services, there is actually a problem with the dns search http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc#Name_Resolver_.2F_DNS I solved it by using consul.service.consul instead of just consul. Try it out docker run --rm gliderlabs/alpine ping consul.service.consul