Docker publish/expose ports properly


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!

Link to comment
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.

Link to comment

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

Link to comment

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

Link to comment
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.

Link to comment
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.

Link to comment
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.

 

Link to comment
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.

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.