Mapping to random host port and discovery question

I’m trying to understand Rancher’s networking. The main problem I’m having now is down to port mapping and discovery by external clients.

If I have ports: “8888:8080/tcp” then this gets mapped correctly to port 8888 on the host. However I can’t seem to work out how to map to a random port under Rancher. If I just have ports: “8080/tcp” then the Rancher console says it’s not mapped to the host at all. I don’t really want to have to hard-code ports for each application as that defeats the object of containerisation.

Also what’s the recommended way of an external client discovering these ports? I know when everything is in Rancher/Docker then we’ll only have a few external ports open but for now the two enviromments need to co-exist.

Sorry for the delay, we currently don’t support random ports. I’ve added a feature to track it in Github.

@denise - you say that publishing to random ports isn’t supported and that’s obviously true when I look at the system. However, it seems like it used to as per the screenshot in this blog post:

Could you tell why this was removed or why this isn’t supported?

@etlweather It was removed as it never actually worked, so we removed it from the UI.

Just to check if I understand this correctly, would the current limitation mean that I can only scale a service to 100 containers when I have 100 hosts since a container with an exposed port can only be launched once per host?

@HappyUser Basically, however with the overlay network, you don’t need to expose the ports - exporting the ports is necessary only if you want the external world to be tied directly to a container which is probably not what you want to do.

In most scenarios - I believe - you would run a load balancer for those containers. The LB does not access the publicly published ports but rather the internal container ports through the overlay network so you can still scale to 100 containers with 1 host.