(SOLVED) Strange Docker Port Mapping


Recommended Posts

Hi All,

 

During routine maintenance I have noticed (What I consider to be) something weird about container mappings on my main unRAID setup.

 

Note: posting here, as I seem to feel that this has nothing to do with any particular container or the docker engine itself.

 

However, I decided to map IP's to each of my containers. Played around with the router and added hostnames too. Easy done. e.g.

 

Custom br0 => 192.168.1.203 => nginx.danioj.lan

 

As I had set the container to run (when it was originally setup in bridge / host mode) on port 81 (due to the conflict with unRAID GUI port 80) I had anticipated having to go to:

 

http://nginx.danioj.lan:81

 

Due to my ever growing laziness, I accidentally left off the port assignment on the URL and (just as I hit enter and expected to find a URL not found error or similar) I was shocked to see that it resolved.

 

What the? It resolved on port 80? I didn't think this was possible, given unRAID GUI runs on port 80. I was also "sure" that even though I have allocated the container to its own LAN IP Address that it still couldn't run on port 80 - there is only one port 80 on the host after all. 

 

EDIT: This is despite me selecting the Host Port in the Container Settings as 81. On the Docker summary page, still shows it is mapping to port 80:

 

192.168.1.203:443/TCP192.168.1.203:443
192.168.1.203:80/TCP192.168.1.203:80

 

Checked and double checked the container settings page. Host port is definitely 81.

 

However, evidence is evidence so I thought, ooooo - Ill change the application port within other containers I have (e.g. emby) to port 80 too meaning I can just access the application using host name and no port. It did not work. Despite the application allowing for the port to be changed (which i did and then restarted), it wouldn't bind to port 80. When it came back up, the port was 8096 (default).

 

What was also wierd though was, I glanced at the port mappings on the docker page in the emby entry and they (despite only having one port mapping for 8096 in the settings of the container) actually showed there was 4 mappings:

 

192.168.1.200:1900/UDP192.168.1.200:1900
192.168.1.200:7359/UDP192.168.1.200:7359
192.168.1.200:8096/TCP192.168.1.200:8096
192.168.1.200:8920/TCP192.168.1.200:8920

 

Again ....What the??? Something screwy is going on here.

 

So, in summary, I have the following:

 

2 containers' settings indicating 1 port mapping (for the default port of the application) but the docker summary page shows that each container has multiple mappings each.

I can access nginx on port 80 when a seperate IP is allocated to that container but not when I try and do the same with another container.

 

I am scratching my head here .....

 

Edited by danioj
Link to comment

I'm sure @bonienl will tell you that the UI is not looking at the template / configuration for the ports in use but rather it constructs it by inspecting the docker container itself for ports (ie docker inspect container). The official EmbyServer has this snippet

"ExposedPorts": {
    "1900/udp": {},
    "7359/udp": {},
    "8096/tcp": {},
    "8920/tcp": {}
},

Also, you need to understand that once the container get its own custom IP address, all the port mappings are ignored, so your unRAID port 80 and nginx port 80 are not in conflict, particularly since the host can't use the custom IP of the container and vice versa. Its like when you run multiple VMs, each with its own IP running a webserver on port 80. To migrate, say emby, to use port 80, you'll need to change the port setting in the server dashboard, and not on the container settings from unRAID UI

 

Hope this make it clear.

  • Upvote 1
Link to comment
On 5/29/2018 at 4:34 PM, ken-ji said:

I'm sure @bonienl will tell you that the UI is not looking at the template / configuration for the ports in use but rather it constructs it by inspecting the docker container itself for ports (ie docker inspect container). The official EmbyServer has this snippet


"ExposedPorts": {
    "1900/udp": {},
    "7359/udp": {},
    "8096/tcp": {},
    "8920/tcp": {}
},

Also, you need to understand that once the container get its own custom IP address, all the port mappings are ignored, so your unRAID port 80 and nginx port 80 are not in conflict, particularly since the host can't use the custom IP of the container and vice versa. Its like when you run multiple VMs, each with its own IP running a webserver on port 80. To migrate, say emby, to use port 80, you'll need to change the port setting in the server dashboard, and not on the container settings from unRAID UI

 

Hope this make it clear.

 

This makes perfect sense, thank you. I understand now. Probably unrealistically, I had expected unused settings to disappear when I selected an option which made them irrelevant and there was no guidance in the help text. 

 

Issue resolved. Thanks again.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.