unable to find tcp host for catalog.services
From the examples/nginx.md at https://github.com/hashicorp/consul-template/blob/master/examples/nginx.md using alpine version v0.22.0 (005b42eb)
I've given a custom host -consul-addr "consul:8500" but it's unable to reach
Screenshot: https://i.stack.imgur.com/1bQrb.png
Configuration
{{range services}} {{$name := .Name}} {{$service := service .Name}}
upstream {{$name}} {
zone upstream-{{$name}} 64k;
{{range $service}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
{{else}}server 127.0.0.1:65535; # force a 502{{end}}
} {{end}}
server {
listen 80 default_server;
location / {
root /usr/share/nginx/html/;
index index.html;
}
location /stub_status {
stub_status;
}
{{range services}} {{$name := .Name}}
location /{{$name}} {
proxy_pass http://{{$name}};
}
{{end}}
}
Dockerfile
FROM hashicorp/consul-template:alpine as template
COPY nginx.conf.ctmpl /tmp/nginx.conf.ctmpl
RUN consul-template -consul-addr "consul:8500" -template="/tmp/nginx.conf.ctmpl:/etc/nginx/conf.d/default.conf"
FROM nginx
COPY --from=template /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
docker-compose
version: '3'
services:
consul:
image: consul:1.6.1
container_name: consul
ports:
- 8300:8300
- 8400:8400
- 8500:8500
service:
container_name: service
build:
context: ./service
dockerfile: Dockerfile
ports:
- 8080:80
depends_on:
- consul
Hey @sweetodev, thanks for the interest and sorry for the delay in reply.
I'm not sure what the problem is exactly other than it looks like a DNS issue (failed lookup). Have you tried asking in one of the community support channels? You might have better luck there as I don't regularly run a docker setup like that and am not sure when I'll have time (it will be a while).
I'll leave this open here for now in case someone sees it and has an idea.