Skip to content

Modern Docker Management, Designed for Everyone

fix: show all network attributes from docker api (#1171)

Kyle Mendell93451a7a8a97
diff --git a/backend/internal/huma/handlers/networks.go b/backend/internal/huma/handlers/networks.go
index 37c56b7f0..f3f0b2aae 100644
--- a/backend/internal/huma/handlers/networks.go
+++ b/backend/internal/huma/handlers/networks.go
@@ -274,6 +274,11 @@ func (h *NetworkHandler) GetNetwork(ctx context.Context, input *GetNetworkInput)
return nil, huma.Error500InternalServerError((&common.NetworkMappingError{Err: err}).Error())
}
+ // Ensure ID is mapped correctly
+ if out.ID == "" {
+ out.ID = networkInspect.ID
+ }
+
// Populate ContainersList
out.ContainersList = make([]networktypes.ContainerEndpoint, 0, len(out.Containers))
for id, container := range out.Containers {
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index ced9b033b..88334ffa2 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -559,10 +559,20 @@
"networks_options_description": "Network driver-specific options",
"attachable": "Attachable",
"ipv6_enabled": "IPv6 Enabled",
+ "ipv4_enabled": "IPv4 Enabled",
+ "ingress": "Ingress",
+ "config_only": "Config Only",
"internal": "Internal",
"network_name_required": "Network name is required",
"unused_networks": "Unused Networks",
"networks_ipam_gateway_label": "Gateway",
+ "networks_peers_title": "Peers",
+ "networks_peers_description": "Overlay network peers",
+ "networks_services_title": "Services",
+ "networks_services_description": "Network services",
+ "networks_service_name_label": "Name",
+ "networks_service_vip_label": "VIP",
+ "networks_service_ports_label": "Ports",
"networks_delete_confirm_message": "Are you sure you want to delete network {name}?",
"networks_remove_confirm_message": "Are you sure you want to remove network {name}?",
"networks_remove_failed": "Failed to remove network {name}",
diff --git a/frontend/src/lib/services/network-service.ts b/frontend/src/lib/services/network-service.ts
index 1fa4ba1d5..669538235 100644
--- a/frontend/src/lib/services/network-service.ts
+++ b/frontend/src/lib/services/network-service.ts
@@ -1,6 +1,6 @@
import BaseAPIService from './api-service';
import { environmentStore } from '$lib/stores/environment.store.svelte';
-import type { NetworkSummaryDto, NetworkUsageCounts, NetworkCreateRequest, NetworkCreateOptions } from '$lib/types/network.type';
+import type { NetworkSummaryDto, NetworkUsageCounts, NetworkCreateRequest, NetworkCreateOptions, NetworkInspectDto } from '$lib/types/network.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import { transformPaginationParams } from '$lib/utils/params.util';
@@ -20,7 +20,7 @@ export class NetworkService extends BaseAPIService {
return res.data.data;
}
- async getNetwork(networkId: string, sort?: string, order?: string): Promise<any> {
+ async getNetwork(networkId: string, sort?: string, order?: string): Promise<NetworkInspectDto> {
const envId = await environmentStore.getCurrentEnvironmentId();
const params: Record<string, string> = {};
if (sort) params['sort[column]'] = sort;
diff --git a/frontend/src/lib/types/network.type.ts b/frontend/src/lib/types/network.type.ts
index 784327a96..fd2e33a27 100644
--- a/frontend/src/lib/types/network.type.ts
+++ b/frontend/src/lib/types/network.type.ts
@@ -69,6 +69,29 @@ export interface NetworkSummaryDto {
isDefault?: boolean;
}
+export interface ConfigReference {
+ Network?: string;
+}
+
+export interface PeerInfo {
+ Name?: string;
+ IP?: string;
+}
+
+export interface Task {
+ Name?: string;
+ EndpointID?: string;
+ EndpointIP?: string;
+ Info?: Record<string, string>;
+}
+
+export interface ServiceInfo {
+ VIP?: string;
+ Ports?: string[];
+ LocalLBIndex?: number;
+ Tasks?: Task[];
+}
+
export interface NetworkInspectDto {
id: string;
name: string;
@@ -84,4 +107,9 @@ export interface NetworkInspectDto {
attachable: boolean;
ingress: boolean;
enableIPv6?: boolean;
+ enableIPv4?: boolean;
+ configFrom?: ConfigReference;
+ configOnly?: boolean;
+ peers?: PeerInfo[];
+ services?: Record<string, ServiceInfo>;
}
diff --git a/frontend/src/routes/(app)/networks/[networkId]/+page.svelte b/frontend/src/routes/(app)/networks/[networkId]/+page.svelte
index 6f2502c8e..92e288b09 100644
--- a/frontend/src/routes/(app)/networks/[networkId]/+page.svelte
+++ b/frontend/src/routes/(app)/networks/[networkId]/+page.svelte
@@ -280,10 +280,142 @@
</p>
</div>
</div>
+
+ <div class="flex items-start gap-3">
+ <div class="flex size-10 shrink-0 items-center justify-center rounded-full bg-indigo-500/10 p-2">
+ <NetworksIcon class="size-5 text-indigo-500" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <p class="text-muted-foreground text-sm font-medium">{m.ipv4_enabled()}</p>
+ <p class="mt-1 text-base font-semibold">
+ <StatusBadge
+ variant={network.enableIPv4 ? 'indigo' : 'gray'}
+ text={network.enableIPv4 ? m.common_yes() : m.common_no()}
+ />
+ </p>
+ </div>
+ </div>
+
+ <div class="flex items-start gap-3">
+ <div class="flex size-10 shrink-0 items-center justify-center rounded-full bg-cyan-500/10 p-2">
+ <SettingsIcon class="size-5 text-cyan-500" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <p class="text-muted-foreground text-sm font-medium">{m.ingress()}</p>
+ <p class="mt-1 text-base font-semibold">
+ <StatusBadge
+ variant={network.ingress ? 'cyan' : 'gray'}
+ text={network.ingress ? m.common_yes() : m.common_no()}
+ />
+ </p>
+ </div>
+ </div>
+
+ <div class="flex items-start gap-3">
+ <div class="flex size-10 shrink-0 items-center justify-center rounded-full bg-pink-500/10 p-2">
+ <SettingsIcon class="size-5 text-pink-500" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <p class="text-muted-foreground text-sm font-medium">{m.config_only()}</p>
+ <p class="mt-1 text-base font-semibold">
+ <StatusBadge
+ variant={network.configOnly ? 'pink' : 'gray'}
+ text={network.configOnly ? m.common_yes() : m.common_no()}
+ />
+ </p>
+ </div>
+ </div>
</div>
</Card.Content>
</Card.Root>
+ {#if network.peers && network.peers.length > 0}
+ <Card.Root>
+ <Card.Header icon={GlobeIcon}>
+ <div class="flex flex-col space-y-1.5">
+ <Card.Title>{m.networks_peers_title()}</Card.Title>
+ <Card.Description>{m.networks_peers_description()}</Card.Description>
+ </div>
+ </Card.Header>
+ <Card.Content class="p-4">
+ <div class="grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3">
+ {#each network.peers as peer}
+ <Card.Root variant="subtle">
+ <Card.Content class="flex flex-col gap-2 p-4">
+ <div class="text-muted-foreground text-xs font-semibold tracking-wide break-all uppercase">{peer.Name}</div>
+ <div
+ class="text-foreground cursor-pointer font-mono text-sm font-medium break-all select-all"
+ title="Click to select"
+ >
+ {peer.IP}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ {/each}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ {/if}
+
+ {#if network.services && Object.keys(network.services).length > 0}
+ <Card.Root>
+ <Card.Header icon={LayersIcon}>
+ <div class="flex flex-col space-y-1.5">
+ <Card.Title>{m.networks_services_title()}</Card.Title>
+ <Card.Description>{m.networks_services_description()}</Card.Description>
+ </div>
+ </Card.Header>
+ <Card.Content class="p-4">
+ <div class="space-y-3">
+ {#each Object.entries(network.services) as [name, service]}
+ <Card.Root variant="outlined">
+ <Card.Content class="p-4">
+ <div class="space-y-2">
+ <div class="flex flex-col sm:flex-row sm:items-center">
+ <span class="text-muted-foreground w-full text-sm font-medium sm:w-24"
+ >{m.networks_service_name_label()}:</span
+ >
+ <code
+ class="bg-muted text-muted-foreground mt-1 rounded px-1.5 py-0.5 font-mono text-xs sm:mt-0 sm:text-sm"
+ >
+ {name}
+ </code>
+ </div>
+ {#if service.VIP}
+ <div class="flex flex-col sm:flex-row sm:items-center">
+ <span class="text-muted-foreground w-full text-sm font-medium sm:w-24"
+ >{m.networks_service_vip_label()}:</span
+ >
+ <code
+ class="bg-muted text-muted-foreground mt-1 rounded px-1.5 py-0.5 font-mono text-xs sm:mt-0 sm:text-sm"
+ >
+ {service.VIP}
+ </code>
+ </div>
+ {/if}
+ {#if service.Ports && service.Ports.length > 0}
+ <div class="flex flex-col sm:flex-row sm:items-start">
+ <span class="text-muted-foreground w-full text-sm font-medium sm:w-24"
+ >{m.networks_service_ports_label()}:</span
+ >
+ <div class="flex flex-wrap gap-1">
+ {#each service.Ports as port}
+ <code class="bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-mono text-xs sm:text-sm">
+ {port}
+ </code>
+ {/each}
+ </div>
+ </div>
+ {/if}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ {/each}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ {/if}
+
{#if network.ipam?.config && network.ipam.config.length > 0}
<Card.Root>
<Card.Header icon={SettingsIcon}>
diff --git a/types/network/network.go b/types/network/network.go
index da15f71ca..026767de1 100644
--- a/types/network/network.go
+++ b/types/network/network.go
@@ -128,45 +128,63 @@ type Inspect struct {
// Required: true
Created time.Time `json:"created"`
- // Options contains driver-specific options.
+ // EnableIPv4 represents whether IPv4 is enabled.
+ EnableIPv4 bool `json:"enableIPv4"`
+
+ // EnableIPv6 represents whether IPv6 is enabled.
+ EnableIPv6 bool `json:"enableIPv6"`
+
+ // IPAM contains IP address management configuration.
//
// Required: true
- Options map[string]string `json:"options"`
+ IPAM network.IPAM `json:"ipam"`
- // Labels contains user-defined metadata for the network.
+ // Internal indicates if the network is internal.
//
// Required: true
- Labels map[string]string `json:"labels"`
+ Internal bool `json:"internal"`
- // Containers is a map of containers connected to this network.
+ // Attachable indicates if the network is attachable.
//
// Required: true
- Containers map[string]network.EndpointResource `json:"containers"`
+ Attachable bool `json:"attachable"`
- // ContainersList is a sorted list of containers connected to this network.
+ // Ingress indicates if the network is an ingress network.
//
// Required: true
- ContainersList []ContainerEndpoint `json:"containersList"`
+ Ingress bool `json:"ingress"`
- // IPAM contains IP address management configuration.
+ // ConfigFrom specifies the source which will provide the configuration for this network.
+ ConfigFrom network.ConfigReference `json:"configFrom"`
+
+ // ConfigOnly networks are place-holder networks.
+ ConfigOnly bool `json:"configOnly"`
+
+ // Containers is a map of containers connected to this network.
//
// Required: true
- IPAM network.IPAM `json:"ipam"`
+ Containers map[string]network.EndpointResource `json:"containers"`
- // Internal indicates if the network is internal.
+ // Options contains driver-specific options.
//
// Required: true
- Internal bool `json:"internal"`
+ Options map[string]string `json:"options"`
- // Attachable indicates if the network is attachable.
+ // Labels contains user-defined metadata for the network.
//
// Required: true
- Attachable bool `json:"attachable"`
+ Labels map[string]string `json:"labels"`
- // Ingress indicates if the network is an ingress network.
+ // Peers is the list of peer nodes for an overlay network.
+ Peers []network.PeerInfo `json:"peers,omitempty"`
+
+ // Services contains service info.
+ Services map[string]network.ServiceInfo `json:"services,omitempty"`
+
+ // ContainersList is a sorted list of containers connected to this network.
//
// Required: true
- Ingress bool `json:"ingress"`
+ ContainersList []ContainerEndpoint `json:"containersList"`
}
type CreateResponse struct {