IceWhaleTech / CasaOS

CasaOS - A simple, easy-to-use, elegant open-source Personal Cloud system.
https://casaos.io
Apache License 2.0
25.87k stars 1.41k forks source link

Add support for network_mode: "container" #321

Closed altShiftDev closed 2 years ago

altShiftDev commented 2 years ago

Is your feature request related to a problem? Please describe. The problem is how to network multiple containers together. Currently this can't be done with CasaOS as it only allows for network mode bridge or host. The use case I need is to have one container running a VPN service (Gluetun) which can then provide that VPN access to other containers as needed (transmission/bittorrent clients).

Describe the solution you'd like In the docker settings "network mode" dropdown, a new option is added to the current list (bridge + host) called "container" and when selected, you would have a new dropdown appear below called "Container" which would allow you to select any other running container to route the traffic through (see screenshots below).

This would be the equivalent of --network=container:gluetun when using docker from the command line or network_mode: "container:gluetun" when using docker from the yml file.

For more info, this is the official instructions from the Gluetun repo on how to network a container to another: https://github.com/qdm12/gluetun/wiki/Connect-a-container-to-gluetun

Describe alternatives you've considered I've tried to manually edit the docker json files inside /var/lib/docker/{appid}/ but I wasn't able to figure out which one to edit and how in order to accomplish this workaround. It seems that these files get overwritten whenever a container restarts. I'll keep looking for command line alternatives to running transmission through gluetun but having the OS support this would be a huge help.

Additional context This video demonstrates the technique through the command line: https://youtu.be/mH7J_2JKNK0?t=330

These screenshot shows this feature demonstrated in the portainer gui:

image image

Video walkthrough of the feature being demonstrated on portainer: https://youtu.be/xbSfaKwyfXE?t=545

Lauren-ED209 commented 2 years ago

This is very interesting! The original plan is to iterate on the network enhancement module in version 0.4. However, as you provided a very clear, easy-to-implement solution, I will evaluate with the team to check if we can provide a quick response in recent updates.

But no doubt, it's an important requirement. It's just a matter of sooner or later.

Lauren-ED209 commented 2 years ago

This suggestion is feasible. Could you share more details about the application scenario? For example, which app do you prefer to communicate with each other based on this network layer? And what are your specific application scenarios?

altShiftDev commented 2 years ago

@Lauren-ED209 The use case that I was trying to do is connect a torrent container (e.g. transmission) to a VPN container (e.g. gluetun). Gluetun can be easily setup with any VPN provider and transmission benefits from the pseudo-anonymity of a VPN.

Lauren-ED209 commented 2 years ago

OK, I'll merge this requirement into the development plan, thanks for your time.

Lauren-ED209 commented 2 years ago

I have created this requirement in the development plan. Recently we are optimizing the routing layer. I would expect to develop this feature you proposed at exactly the right time when the routing layer development is complete.

I'll close this issue, feel free to share with us on discord or here if you have further ideas!

drakoooo commented 1 year ago

Hello, i'm currently struggling to find that feature for the same exact need of op, is it still not implemented ? and if not, are there any simple way to make it work ? I really don't want to setup a Portainer just for that.

altShiftDev commented 1 year ago

Hello, i'm currently struggling to find that feature for the same exact need of op, is it still not implemented ? and if not, are there any simple way to make it work ? I really don't want to setup a Portainer just for that.

I ended up finding a transmission+openVPN hybrid project on docker which works well enough for me. I'm not sure if what I originally wanted to do is possible yet or not though.

drakoooo commented 1 year ago

I ended up finding a transmission+openVPN hybrid project on docker which works well enough for me. I'm not sure if what I originally wanted to do is possible yet or not though.

Thanks a lot for your answer ! Sadly, i need gluetun for another container that can't use any vpn. I guess i'm gonna have to use portainer if this not implemented... I tried a few things on the command line of my debian, but, as a total newbie who installed his first home server 5 days ago, i wasnt able to make it work. I think it might be possible tho, with a mentionned docker command on the casaos's discord i believe, which was "docker network connect < network > < container name >" but for now, I don't have the experience to understand it. I hope it will be added in a next update, as I could wait a little before using the container passing through a VPN.

subcidr commented 1 year ago

In the same boat here, running Gluetun in one container and binding that to other containers who need a vpn. This doesn't seem possible to do in CasaOS, yet? Otherwise CasaOS is amazing!

altShiftDev commented 1 year ago

A final solution which I experimented with is to use docker compose to manually do what you want and bypass the casa os UI. It got a bit annoying to maintain overtime but it should work.

drakoooo commented 1 year ago

Hello, i tought the docker compose way wasnt possible, so i'll try it when i can, but the problem is, you have to install the container you wanna pass through gluetun again if it's already installed right ? Sorry, for my noob questions, but maybe you can edit a docker compose of a container through ssh ? Anyways, should i open another issue for this feature request ? As it's already closed.

chinarut commented 6 months ago

thank you @altShiftDev for the YouTube video - worked like a charm!

I have created this requirement in the development plan. Recently we are optimizing the routing layer. I would expect to develop this feature you proposed at exactly the right time when the routing layer development is complete.

I'll close this issue, feel free to share with us on discord or here if you have further ideas!

@Lauren-ED209 could you please provide a link to the development plan?

I feel like we’ve lost the ability to track and trace this issue by closing it when it is not implemented. please let me know if I’m wrong.

hotstormt commented 3 months ago

Hello,

I'm experiencing the same issue mentioned earlier and would like to know whether this functionality has been added to the roadmap or if it has been overlooked. In today's world, using a VPN is essential for maintaining anonymity online, and I believe this feature is crucial for many CasaOS users.

Currently, the limitation of only having bridge or host network modes makes it difficult to integrate essential services like VPNs with other containers, often forcing users to seek alternative, sometimes cumbersome, solutions like manually editing configuration files or using Docker Compose.

Adding a "container" network mode within Docker settings in CasaOS would be a significant improvement and make it much easier for users to ensure their privacy and security when using services like torrents via VPN.

I'd like to emphasize the importance of this request and kindly ask for an update on the status of this functionality in the CasaOS development plan.

Thank you for your attention and for the great work so far!