azukaar / Cosmos-Server

☁️ The Most Secure and Easy Selfhosted Home Server. Take control of your data and privacy without sacrificing security and stability (Authentication, anti-DDOS, anti-bot)
https://cosmos-cloud.io
Other
3.1k stars 112 forks source link

[FEAT]: Improving networks when creating a container #115

Closed SSTentacleSS closed 10 months ago

SSTentacleSS commented 10 months ago

Feature Description

A small change aimed at improving the naming of networks, when I want, for example, to create a new container - I expect that when specifying label

cosmos-network-name: network-name

instead of AUTO, with this parameter set, it would be intuitively better if cosmos itself created a network with the name specified in cosmos-network-name, now cosmos ignores this parameter and writes a random network name there and uses a random network accordingly

SSTentacleSS commented 10 months ago

Perhaps it makes sense to create a network in ConnectToSecureNetwork instead of creating a random one

Or, for example, specify one additional label that will force cosmos-server to create this network

azukaar commented 10 months ago

Cosmos does not ignore the parameter, it creates a new network when cosmos-network-name does not exist (as in you didn't create the network). If it does exist, it will follow the label If you are trying to import a docker-compose and absolutely want the container network to have a specific name, you should create the network in the network part of the compose file

{ "services": ..., "networks": [ ... here ] }

Closing the ticket for now but feel free to continue the conversation

SSTentacleSS commented 10 months ago

Creates a network, but with a random name, which is sometimes not quite what you would like and what you expect, especially when docker-compose is not used, but Market is used

Cosmos does not ignore the parameter, it creates a new network when cosmos-network-name does not exist (as in you didn't create the network). If it does exist, it will follow the label If you are trying to import a docker-compose and absolutely want the container network to have a specific name, you should create the network in the network part of the compose file

{ "services": ..., "networks": [ ... here ] }

Closing the ticket for now but feel free to continue the conversation

As I looked, it creates a network, but with a random name, which is sometimes not quite what you would like and what you expect, especially when docker-compose is not used, but Market is used

Yes, of course, you can create a network yourself with the specified name, but wouldn’t it be better to add an option so that cosmos creates a network that is not random, but specifically specified?

I apologize in advance for possible intrusiveness, I’m generally ready to create a network manually, just offering a possible option as I see it

azukaar commented 10 months ago

Sorry for the misunderstanding, I didn't mean to say you had to create the network manually but you do have to declare it in the compose file in order for it to exist. For example like this:

https://github.com/azukaar/cosmos-servapps-official/blob/master/servapps/Immich/cosmos-compose.json#L173

The randomized network when network does not exist is to prevent stopped network from connecting to newly created network (you can remove a network while having a stopped container connected to it. If you re-create the network, the old container will re-connect to it)

SSTentacleSS commented 10 months ago

Hmm, okay, got you, thanks!

Then maybe it’s worth adding options for editing official compose files in Market? or is it possible to expand customization by adding the option to add/remove networks as in the compose file?

azukaar commented 10 months ago

For the market it's different, as the wizard does not let you customize to this extent (you can customize more relevant stuff like env vars, volumes and binds). Creating a new random network is the intended behaviour for the market