unraid / webgui

Unraid Web UI
146 stars 71 forks source link

[Docker] Add the ability to select multiple custom networks for containers #1812

Open andrebrait opened 1 month ago

andrebrait commented 1 month ago

Disclaimer: this is more of an RFC as I intend to implement this myself and submit a PR.

The problem

Since version 25.0, docker run takes multiple --network arguments, meaning we can now connect containers to multiple (custom) networks. Unraid, however and from what I can see on the master branch here, allows only for a single network to be selected.

The proposal

Turn the network selection field into a checkbox list. Some restrictions must apply, to reflect limitations of the docker run command, such as not being possible to select both bridge/host networks at the same time as custom ones.

Complications

The syntax to expose ports must address the fact ports can now be exposed for different networks.

mtongnz commented 1 month ago

I had a similar thought to this and have been toying with it over the last month: https://github.com/mtongnz/unRaid-webgui/tree/docker-multiple-networks

So that this worked on the current version of unRaid, I took the approach of using network connect to get around the older version of docker not allowing multiple networks via the run command. I changed docker run to docker create, then multiple network attach (if needed), then docker start. This ensures networks are attached prior to the container starting. This approach is pretty easy to change in the future when docker is updated. I also used a format that would accept the current templates with a single network so it wouldn't impact the container templates currently in use.

Would be interested in your thoughts.

andrebrait commented 4 weeks ago

@mtongnz it looks exactly like what I'd like. I can't patch cleanly on top of my installation because it's missing some folders, though (e.g. emhttp/plugins/dynamix.docker.manager/sheets') and I'm not sure what to do there

mtongnz commented 4 weeks ago

What unRAID version are you on?

andrebrait commented 4 weeks ago

@mtongnz 6.12.11

mtongnz commented 4 weeks ago

It should work then. I only modified the existing files. I didn't add/delete anything

andrebrait commented 4 weeks ago

@mtongnz hm, weird. The entire folder is missing for me. I assume there isn't a build script that processes it somehow?

andrebrait commented 4 weeks ago

@mtongnz mystery solved: the folder does not exist in the 6.12 branch (in all tags that it includes), only on master and tags 6.13.0-beta1 and later.

mtongnz commented 4 weeks ago

Screenshot_20240816_191444_GitHub.jpg

It's showing in my repo on GitHub on my phone... Not sure why it's not showing for you

andrebrait commented 4 weeks ago

@mtongnz it's showing on my phone too. The folder does not exist on my server because it's running 6.12.11.

The folder only exists in 6.13 (a.k.a. 7) and later, and master, of course.

mtongnz commented 4 weeks ago

Ah... That makes sense. I'd forked the master branch on GitHub

andrebrait commented 4 weeks ago

No problem. An improvement like this probably won't make it to 6.12 anyway, so I'll update to the next beta of 7 and go from there.

mtongnz commented 4 weeks ago

I'm running 6.12 but with the latest webui version. I'll wait to update unRAID until it's stable as my server is critical. It seems to run fine. If there's issues, a server reboot reverts the UI to the installed version.

andrebrait commented 4 weeks ago

You mean you downloaded it from here and uploaded it to your server?

mtongnz commented 4 weeks ago

You mean you downloaded it from here and uploaded it to your server?

I use VSCode with git for versioning, and STFP to sync the files to my unRaid. So in VSCode, I can have multiple branches of code that I switch between and then sync them to unRaid to test. SFTP can also be set to auto-push any changes as you save them. https://docs.pantheon.io/guides/sftp/vscode-sftp

On unRaid, create an SSH key and save it to somewhere accessible from VSCode. Here's the folder structure for the unRaid/webgui project: image

Here's my sftp.json: { "name": "unRaid", "host": "192.168.1.123", "protocol": "sftp", "port": 22, "username": "root", "privateKeyPath": ".vscode/ssh.key", "remotePath": "/usr/local", "uploadOnSave": true, "useTempFile": false, "openSsh": true, "ignore": [ "// comment: ignore dot files/dirs in root of repo", ".vscode", ".git", ".DS_Store", "// comment: ignore symlinks in repo", "sbin/emcmd", "sbin/plugin", "sbin/language", "sbin/newperms", "sbin/inet", "sbin/samba", "sbin/diagnostics", "emhttp/boot", "emhttp/state", "emhttp/mnt", "emhttp/log", "emhttp/plugins/dynamix/images/case-model.png", "emhttp/webGui", "// comment: ignore files distributed by Unraid Connect", "emhttp/plugins/dynamix.my.servers", "emhttp/plugins/dynamix/include/UpdateDNS.php" ] } All you should need to update in the config is the IP.