# Mapping to random host port and discovery question

**URL:** <https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339>\
**Category:** Rancher 1.x\
**Created:** [August 27, 2015, 10:51am UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339 "2015-08-27T10:51:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiboro](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@kiboro](https://forums.suse.com/u/kiboro)\
**Post date:** [August 27, 2015, 10:51am UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339/1 "2015-08-27T10:51:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [September 22, 2015, 7:01pm UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339/2 "2015-09-22T19:01:38Z")

</div>

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

> <https://github.com/rancher/rancher/issues/2097>
>
> Allow the ability to map to random ports.

---

<div class="post-metadata">

**Author:** ![etlweather](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/etlweather/32/419_2.png) [@etlweather](https://forums.suse.com/u/etlweather)\
**Post date:** [October 26, 2015, 11:35pm UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339/3 "2015-10-26T23:35:01Z")

</div>

@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: [http://cdn.rancher.com/wp-content/uploads/2015/05/27094511/Screen-Shot-2015-05-20-at-11.11.40-PM.png](http://cdn.rancher.com/wp-content/uploads/2015/05/27094511/Screen-Shot-2015-05-20-at-11.11.40-PM.png)

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

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [October 28, 2015, 4:24am UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339/4 "2015-10-28T04:24:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![HappyUser](https://avatars.discourse-cdn.com/v4/letter/h/41988e/32.png) [@HappyUser](https://forums.suse.com/u/HappyUser)\
**Post date:** [October 28, 2015, 4:26pm UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339/5 "2015-10-28T16:26:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![etlweather](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/etlweather/32/419_2.png) [@etlweather](https://forums.suse.com/u/etlweather)\
**Post date:** [October 28, 2015, 7:44pm UTC](https://forums.suse.com/t/mapping-to-random-host-port-and-discovery-question/339/6 "2015-10-28T19:44:57Z")

</div>

@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.
