1

I am trying to connect to a Consul server hosted in a Docker container.

I used the below command to launch the Consul server on docker,

docker run -d -p 8500:8500 -p 8600:8600/udp --name=CS1 consul agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0 -bind=0.0.0.0

The Consul sever is successfully launched and I can access the UI on my host machine using the URL http://localhost:8500/ui/dc1/nodes.

Below is the log for the Consul server as shown by Docker,

==> Starting Consul agent...

Version: '1.9.2'

Node ID: 'cc205268-1f9d-3cf6-2104-f09cbd01dd9d'

Node name: 'server-1'

Datacenter: 'dc1' (Segment: '<all>')

Server: true (Bootstrap: true)

Client Addr: [0.0.0.0] (HTTP: 8500, HTTPS: -1, gRPC: -1, DNS: 8600)

Cluster Addr: 172.17.0.2 (LAN: 8301, WAN: 8302)

Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false, Auto-Encrypt-TLS: false

Now I have a .Net core 3.1 web api service which I am trying to register with the Consul server. The service is running on the host machine. I'm using IP address 172.17.0.2 and Port 8500.

However I'm unable to register the service and I get an error message as below,

The requested address is not valid in its context.

I would appreciate if anyone can suggest if I'm doing anything wrong or how to register a service running on host machine with a Consul server hosted in a docker container?

2
  • Can you also share the service definition you are using? Commented Jan 24, 2021 at 21:01
  • @BlakeCovarrubias: My service is actually an API Gateway which is using Ocelot. ocelot.readthedocs.io/en/latest/features/servicediscovery.html. My definition in the service config file is "ServiceDiscoveryProvider": { "Scheme": "http", "Host": "172.17.0.2", "Port": 8500, "Type": "Consul" }. Commented Jan 24, 2021 at 22:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.