# Port mapping to Rancher network

**URL:** <https://forums.suse.com/t/port-mapping-to-rancher-network/2513>\
**Category:** Rancher 1.x\
**Created:** [April 18, 2016, 8:07pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513 "2016-04-18T20:07:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 18, 2016, 8:07pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/1 "2016-04-18T20:07:11Z")

</div>

Hello all,

In advance sorry if my question has been already raised but I did not manage to find the answer.

I have a simple requirement, being able to access a container from its private port onto the Rancher managed network.

Let’s imagine I have deployed a new Docker instance on 172.17.0.2 without exposing any port on the host machine. But still, if my container has a private port 8080, I am able to accessible from **172.17.0.2:8080**.

Now I would like to do the same thing from the Rancher managed network. The same container is also accessible from the managed network to 10.42.216.20, but I cannot access its private port **10.42.216.20:8080**.

So, is there any way to do it?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [April 18, 2016, 11:13pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/2 "2016-04-18T23:13:41Z")

</div>

Access from where? Any port that is listening on any container with managed networking is accessible from elsewhere in the managed network, e.g. other containers. But that is not accessible from, say, your laptop.

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 18, 2016, 11:28pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/3 "2016-04-18T23:28:40Z")

</div>

Even if the port is not mapped onto the host machine? It is actually my test case, a port exposed but not mapped anywhere.  
But I wonder how to access it from the Rancher managed network (let’s say another instance running in the same managed network).

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 18, 2016, 11:51pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/4 "2016-04-18T23:51:43Z")

</div>

The port 8080 is not mapped on any interface so far but it is exposed though:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
62b887f00147 elasticsearch:0.7.0 “/usr/lib/jvm/java-8-” 4 minutes ago Up 3 minutes 8051/tcp r-Default\_ES\_1

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 19, 2016, 3:45pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/5 "2016-04-19T15:45:30Z")

</div>

It still does not work ☹

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 21, 2016, 2:25pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/6 "2016-04-21T14:25:19Z")

</div>

It should and it shouldn’t require any special configuration.

Can you run this command in your container to ensure it’s actually listening please:

```
netstat -ltn
```

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 21, 2016, 4:26pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/7 "2016-04-21T16:26:48Z")

</div>

Thanks for your help.

I ran the command (on my host OS) but unfortunately I did not get anything related to my container IP (by container IP I mean the private IP within the Rancher managed network ofc).

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 21, 2016, 10:20pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/8 "2016-04-21T22:20:03Z")

</div>

Sorry I just saw you asked me to run this command within my container.

I have some troubles to install net-tools for netstat but if I run a docker inspect, I do see:

`"Config": { ... "ExposedPorts": { "8051/tcp": {} }`

and

`"NetworkSettings": { "Bridge": "", ... "Ports": { "8051/tcp": null },`

With a `$ss -l` I got:

`tcp LISTEN 0 128 ::ffff:172.17.0.5:8051 :::*`

But still not reachable from other container within the Rancher network.

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 22, 2016, 12:38pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/9 "2016-04-22T12:38:37Z")

</div>

I actually told you to use `netstat` as most of the time that is available and `ss` is not 😉

It looks like you ran the `ss` command on the host, not the container, hence the 172.x.x.x address shown. That, or your container is using host mode networking? Which is it?

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 22, 2016, 5:26pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/10 "2016-04-22T17:26:01Z")

</div>

No I ran the ss command from my container.

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 22, 2016, 6:41pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/11 "2016-04-22T18:41:08Z")

</div>

And I’m not using the host mode. I use the managed option.  
My goal is to expose something on 10.42.x.x not on 172.x.x.x

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 25, 2016, 1:43pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/12 "2016-04-25T13:43:04Z")

</div>

Odd then that we see the host IP address in the `ss` output. Can you run a `ifconfig` or `ip a` in the container to confirm please. If that shows a 10 address, we know we’re good.

Btw, you’ve switched from port 8080 to 8051, I assume your testing has also changed to accommodate that? How are you testing connectivity?

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 25, 2016, 8:39pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/13 "2016-04-25T20:39:33Z")

</div>

Hi,

An ip command within a container:

`root@a2ed30efbe60:/component# ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 43: eth0@if44: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:68:da:ba:13:d4 brd ff:ff:ff:ff:ff:ff inet 172.17.0.5/16 scope global eth0 valid_lft forever preferred_lft forever inet 10.42.212.155/16 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::68:daff:feba:13d4/64 scope link valid_lft forever preferred_lft forever`

From my point of view this looks like pretty normal. We do see the internal Docker IP (172.17.x.x) and the Rancher IP (10.42.x.x). Do you confirm?

Yes I switched to 8051, actually I used 8080 at the beginning just for the description. My private port is still 8051.

I am testing connectivity from another container (basically a tcp call), launched with Rancher using managed network and I created a link between both containers.

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 25, 2016, 8:47pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/14 "2016-04-25T20:47:51Z")

</div>

I don’t understand though when you said we see the host IP address in the ss output…

When I executed the $ss command from my container, I got a 172.17.0.0/16 IP which is my private Docker IP (managed within the docker0 interface)

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 25, 2016, 9:02pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/15 "2016-04-25T21:02:50Z")

</div>

By the way a netstat command output, still from my container exposing the 8051 private port:

`root@a2ed30efbe60:/component# netstat Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp6 0 0 a2ed30efbe60:33380 192.168.56.101:2181 ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 2 [] STREAM CONNECTED 88612 unix 2 [] STREAM CONNECTED 89580`

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [April 29, 2016, 3:18pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/16 "2016-04-29T15:18:26Z")

</div>

No idea please ☹ ?

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [May 6, 2016, 4:14pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/17 "2016-05-06T16:14:59Z")

</div>

Hey.

Apologies, getting my IP’s confused.

It’s odd that that listening port is only shown listening on an IPv6 address. Normally I’d expect to see \*:8051 or :::8051 for the Local Address: Port.

Perhaps some Java misconfiguration? Or maybe just your OS.

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [May 24, 2016, 7:50pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/18 "2016-05-24T19:50:08Z")

</div>

I guess I will have to find another solution. This standard way is not working and this is actually pretty disappointing.

---

<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:** [May 24, 2016, 8:46pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/19 "2016-05-24T20:46:01Z")

</div>

Are you using a host with ipv6? If so, that’s not supported.

[https://github.com/rancher/rancher/issues/1403](https://github.com/rancher/rancher/issues/1403)

---

<div class="post-metadata">

**Author:** ![teivah](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/teivah/32/1230_2.png) [@teivah](https://forums.suse.com/u/teivah)\
**Post date:** [May 24, 2016, 8:58pm UTC](https://forums.suse.com/t/port-mapping-to-rancher-network/2513/20 "2016-05-24T20:58:24Z")

</div>

Hi Denise,

Nope I am using plain old ipv4.

[Next page](https://forums.suse.com/t/port-mapping-to-rancher-network/2513.md?page=2)
