feat: expose whether a network was created by dokku

`network:list` and `network:info` now expose a `DokkuManaged` boolean derived from the `com.dokku.network-name` label that `network:create` applies, and `network:list` gains a `--dokku-managed` flag to restrict output to dokku-created networks. This lets tooling distinguish networks dokku created from Docker built-ins and networks created by other tooling such as compose.
This commit is contained in:
Jose Diaz-Gonzalez
2026-07-08 00:03:29 -04:00
parent 24e3809a34
commit ac4b86fd8e
6 changed files with 113 additions and 23 deletions

View File

@@ -11,15 +11,21 @@ import (
"github.com/dokku/dokku/plugins/common"
)
// dokkuNetworkNameLabel is the docker label network:create applies to every
// network it creates. Its presence is the marker used to identify a network as
// dokku-managed.
const dokkuNetworkNameLabel = "com.dokku.network-name"
type DockerNetwork struct {
CreatedAt time.Time
Driver string
ID string
Internal bool
IPv6 bool
Labels map[string]string
Name string
Scope string
CreatedAt time.Time
DokkuManaged bool
Driver string
ID string
Internal bool
IPv6 bool
Labels map[string]string
Name string
Scope string
}
// attachAppToNetwork attaches a container to a network
@@ -206,6 +212,10 @@ func getNetworks() (map[string]DockerNetwork, error) {
network.Labels[key] = value
}
if _, ok := network.Labels[dokkuNetworkNameLabel]; ok {
network.DokkuManaged = true
}
networks[network.Name] = network
}