Skip to content

Conversation

@ttugrul
Copy link
Contributor

@ttugrul ttugrul commented Dec 25, 2025

Motivation

When CloudNet runs inside a containerized environment (e.g., Docker with bridge networking) with a host address that doesn't exist in the container's network namespace, the port allocation fails with "No free port found" error. This happens because NetworkUtil.isInUse() tries to bind a ServerSocket to an address that doesn't exist locally, causing all port checks to fail.

Modification

  • Added NetworkUtil.isBindableAddress() method to check if an address exists in the current network namespace
  • Updated BaseLocalCloudServiceFactory.isPortInUse() to skip OS-level port validation for external addresses and rely on the CloudNet service registry instead

Result

CloudNet can now correctly allocate ports when running in containerized environments with external host addresses. The service registry is used to prevent port conflicts for addresses outside the local network namespace.

@derklaro
Copy link
Member

derklaro commented Dec 26, 2025

I wonder if overriding the method in DockerizedLocalCloudServiceFactory would be a better option. Right now providing an address that the service cannot bind to for jvm services (running on the host) would pass the port check, start the service and then fail when binding, or am I missing something?

EDIT: Plus, the check also fails if another service also runs on the host/port combination (first check of the method), that seems undesireable for dockerized services as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants