Jump to content
theLine

Docker publish/expose ports properly

12 posts in this topic Last Reply

Recommended Posts

Hi, I'm using Unraid 6.6.7 and having some issues when trying to publish/expose docker ports.

 

In my example I want to publish both UDP ports 27015 and 34197.
Unraid will display that the ports are published, but I can't access them.

 

Here is the command that will be executed:

root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='factorio' --net='br0' --ip='192.168.2.20' -e TZ="Europe/Berlin" -e HOST_OS="Unraid" -e 'UDP_PORT_27015'='27015' -e 'UDP_PORT_34197'='34197' -v '/mnt/user/appdata/factorio':'/factorio':'rw' 'dtandersen/factorio' 

As you can see Unraid is using -e 'UDP_PORT_34197'='34197' instead of -p 34197:34197

 

I've seen other installations that were using the "-p" instead of the "-e" argument.
Now I'm asking how can I configure that Unraid will use the "-p" argument?

 

Thanks in advance!

Share this post


Link to post
25 minutes ago, theLine said:

Hi, I'm using Unraid 6.6.7 and having some issues when trying to publish/expose docker ports.

 

In my example I want to publish both UDP ports 27015 and 34197.
Unraid will display that the ports are published, but I can't access them.

 

Here is the command that will be executed:


root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='factorio' --net='br0' --ip='192.168.2.20' -e TZ="Europe/Berlin" -e HOST_OS="Unraid" -e 'UDP_PORT_27015'='27015' -e 'UDP_PORT_34197'='34197' -v '/mnt/user/appdata/factorio':'/factorio':'rw' 'dtandersen/factorio' 

As you can see Unraid is using -e 'UDP_PORT_34197'='34197' instead of -p 34197:34197

 

I've seen other installations that were using the "-p" instead of the "-e" argument.
Now I'm asking how can I configure that Unraid will use the "-p" argument?

 

Thanks in advance!

I think you should show a screenshot of the docker settings page for that container.    The -e option suggests you have set up environment variable mappingrather than port mapping.

Share this post


Link to post

Here's a screenshot of my container configuration

The weird this is, that all of my docker containers (e.g. Plex) are using the "-e" option... 🤔

unraid.png

Share this post


Link to post

The reason is that you have set it to use a bridge and assigning an IP. Then the container port will be used and you can't publish any ports. It's the same as using host networking. Unraid then switch the -p to -e automatically. Don't know why they did that instead of just removing it from the run command though....

Share this post


Link to post
19 hours ago, saarg said:

Don't know why they did that instead of just removing it from the run command though....

This is done to make assignments visible, see "Show Docker allocations"

Share this post


Link to post

Basically you're right, and in this example there's no need for it.

 

But I'm using NginxProxyManager which uses 8080 and 4443 respectively. For external access I can use port-forwarding in my firewall to remap 8080 to 80 and 4443 to 443.

Unfortunately I can't use the local IP addresses then.

 

P.S.: I'm using NginxProxyManager  just for ease of use.

Maybe I have to use a "proper" nginx/Let's Encrypt docker container for that... 

Share this post


Link to post
29 minutes ago, theLine said:

For external access I can use port-forwarding in my firewall to remap 8080 to 80 and 4443 to 443.

I don't see why not.

You can still use external ports 8080 and 8443 and map them internally to ports 80/443 and the associated IP address of the container.

Share this post


Link to post
1 hour ago, bonienl said:

This is done to make assignments visible, see "Show Docker allocations"

But they are not valid and is just there to confuse as far as I see it. It's still in the template, visible, even if it's removed from the run command.

Share this post


Link to post
12 hours ago, saarg said:

But they are not valid and is just there to confuse as far as I see it. It's still in the template, visible, even if it's removed from the run command.

They indicate which port(s) are used by the container, I don't see anything confusing about that.

 

The containers list and resources are retrieved from reading docker directly to ensure their 'validity', the templates are only used for configuration.

 

Share this post


Link to post
12 hours ago, bonienl said:

They indicate which port(s) are used by the container, I don't see anything confusing about that.

 

The containers list and resources are retrieved from reading docker directly to ensure their 'validity', the templates are only used for configuration.

 

If you are readin docker directly for ports, why do you need to add it as a variable to the run command? When it's in a custom bridge or host, it's only the container port that is anything to care about, and that you read from docker directly you say.

 

It's confusing for people that doesn't know how the internals of unraid work when they see that the ports are suddenly set as variables, when they expect a port mapping.

Share this post


Link to post

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.