Docker (Docker compose) always listen in localhost port even if the process of the container is stopped


I have in a host, one container that use two ports, 5050 and 5051 (two instances).
Then, I need to only bind these ports to localhost (


  • ports:
    • “”
    • “”

Then, I have an alarms to check TCP connection to localhost:
check_tcp -H -p 5050
check_tcp -H -p 5051

When the two instances are UP, then I get an OK.

If I enter in the container, and, for example, kill one one instance (example 5051), and go back to the host and launch the checks (or do ncat -v 5050/5051):
check_tcp -H -p 5050
check_tcp -H -p 5051

Then, always get an OK, but the check of 5051 shoud fail, but not.

If I bind the container to all “”, and change the checks to:
check_tcp -H hostip -p 5050
check_tcp -H hostip -p 5051

And kill the 5051 instance in the container, then the 5051 check is executed with failed state (correct).

It is a bug?

Cesar Jorge