eaglewu
eaglewu

Reputation: 470

Docker reuse port in a consul TCP health check cycle

Examples:

moment 1: Docker run container A that listen 32781(export port)->8000(service port) Consul health check done pass by TCP connection(cycle 10s).

moment 2: Docker restart container A and run container B at close time(Less than 10s). Now the port 32781 is container B (reuse port), the new container A got another port.

But next cycle of consul health check, the port 32781 is ok, and the consul take for container A is ok.

How to solve the issue?

Upvotes: 1

Views: 579

Answers (1)

Stanislav
Stanislav

Reputation: 28106

It seems to me, you have to deregister a service and it's health checks on container restart. Consul API provide such an opportunity, you just have to use it in your microservices. How to exactly make it work, depends on the way your services are built. Otherwise, no way Consul will determine, that some service was restarted with another port.

Upvotes: 1

Related Questions