Separated networks - #3
Conversation
Set the CUSTOMS_NETWORKS environment variable to add multiple networks ex: CUSTOMS_NETWORKS=apps-internal-custom,app-external
Set the network.to.connect container LABEL for define the networks to connect the container
ex:
services:
swag:
container_name: swag
.......
labels:
- network.to.connect=apps-internal-custom,app-external
Some update in logs lines
|
This is a great idea! Keeping apps only on their relevant networks can improve security posture. I have a few minor suggestions:
I can go ahead and make these changes, or you could make them yourself if you prefer. Let me know what you think! |
|
Also, what do you think about creating networks on-the-fly rather than explicitly defining them in the environment variable beforehand? So all you would need to do is set the label I also think we should probably add labels to networks created by Dragonify so it can manage their lifecycle (e.g., deleting them when no longer in use). |
Change LABEL for Following Docker's recommendations
|
Hi
|
Add CONNECT_ALL ENV variable to maintain backward compatibility. Set it to "false" or "False" for disabling the auto-connection of all containers to the default apps-internal network
Adds a check for existing networks when connecting to networks in order to create one if necessary
Add a function to delete networks that are no longer in use
Remove the default network if the CONNECT_ALL ENV is set to "false" or "False"
|
Hum,
Personally I use it like this and it works very well: DragonifySWAG |
|
this container and especially this pull request is a lifesaver! congrats to you @tjhorner and @casse-boubou. i just changed the dns name to {service}.truenas. is more convenient. my use case is a swarm over all my docker hosts and have a proxy overlay network for the reverse proxy. i use the swarm with standalone containers, no high availability. only truenas was a bit of a headache with networks. i am really happy i found this project. i testet the pull request intensely and it works like a charm. please @tjhorner commit it. |
from seeing the app try to create a network that already exists
correct image name
Make Main Branch Distroless
Added comments for using a prebuilt image option.
|
Since this PR is not merged I cannot see how to run this version as described using I think I can probably make it work short-term using @tjhorner Can we get this merged? |
|
P.S. This PR needs to update the documentation to show two ways of running the service. And IMO this is so useful that it should be contributed to the Truenas App directory. |
|
I have a refactored version of Dragonify coded, and it is compiling cleanly but not yet tested - but I have gone back a few steps:
I am part way through documenting my (as yet incomplete) vision, and would welcome your input. Please see the work-in-progress README.md at https://github.com/Sophist-UK/dragonify/blob/main/README.md I would welcome any comments on my ideas - and please don't hold back. |
Fix network existence check and race condition handling
Almost completely rewrites the code to add a concept of tuple variables in order to manage the connection/reconnection of an existing container to a new network.
Handle Docker shutdown to obtain an exit code: 0
- reduces the number of calls to the Docker API in the event of a container stop. Thus accelerating the execution speed - changes the way networks are prunned in order to avoid performing a prune of all networks at each container stop
Apply a timer to prune network to prevent it from triggering at each container stop. Truenas already executes this function when restarting an app and this caused a conflict if Drogonify deleted the network before Truenas could reuse it

Thank you for your work.
I think this addition could be very useful, please take a look.
Description:
Context:
Hi,
I've only had my very first NAS server for two weeks, and 25.04 is my first version.
So I'm not familiar with the capabilities you had with version 24.04, but having encountered issues connecting SWAG and some common services, I found your Custom_App after reading your discussion.
First of all, a GREAT GREAT THANK YOU! Using the container name as an identifier rather than its IP address is a basic principle for me, and I don't understand why it's missing from TrueNas. So thank you for your excellent work!!!
However, more than a network to bring them all (....and in the darkness bind them in), it's important for me to differentiate networks. Not all applications need to be networked, and not all need to be on the same network.
With this update, it's now possible to separate networks, and even better, a LABEL is enough to add an APP container to a network.
This also works with official or community apps.
HOW TO:
Networking
Networks are created by adding the CUSTOMS_NETWORKS ENV variable, separated by a comma.
This variable is not required, and if it is not set, the default value "apps-internal" will be used.
Connecting containers
To connect a container to a network, assign it the LABEL network.to.connect.
Multiple networks can be configured, separated by a comma.
Config by YAML
Setting up an APP Community