Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Surface Docker network attachments

rcourtman9dfadc38e555
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index d46e51f110..94878d5741 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -250,6 +250,14 @@ hydrated from runtime disk-usage data. Kubernetes deployments must surface the
API-native observed generation and metadata age columns through the shared
table shell without page-local alignment helpers or generic infrastructure
columns.
+Docker network rows use the same shared table/detail primitive split:
+the default table columns prioritize attached workloads, attention state,
+subnets, driver, and host, while lower-level scope, addressing, flags, and
+network id details belong in the inline row disclosure. Attached container
+names, network addresses, image, health/state, and published ports are
+feature-owned data, but search and disclosure behavior must remain inside the
+shared table chrome rather than a card deck, nested card, or route-changing
+object browser.
1. `frontend-modern/src/components/Settings/APIAccessPanel.tsx` shared with `security-privacy`: the API Access settings intro is both a security/privacy token-management trust surface and a canonical settings-shell presentation boundary.
The panel may own shell placement and local action layout, but
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 0599f2f588..0b9f46c616 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -218,6 +218,16 @@ those rows through a variant-switched generic inventory table. Swarm service
rows must preserve the service update status emitted by the Docker adapter, and
engine storage rows must stay host-scoped with table proof hooks so browser
proof can distinguish a populated disk-usage tab from an empty fixture.
+Docker network rows must consume canonical runtime attachment relationships,
+not page-local topology inference, when the unified-resource snapshot provides
+them. Runtime container-to-network membership is represented as active
+`attached_to` relationships from the `app-container` resource to the
+`docker-network` resource, scoped to the reporting Docker host and discoverer,
+with the same edge visible on both resources so network workflow tables and
+resource drawers can explain the relationship from either endpoint. The
+Docker Networks table may keep a host-scoped legacy `docker.networks[]`
+fallback only for older snapshots that have not yet published the relationship
+edge; that fallback must not match containers across Docker hosts.
1. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts` shared with `performance-and-scalability`: the infrastructure selector pipeline is both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
2. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts` shared with `performance-and-scalability`: resource detail mappers are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
@@ -326,6 +336,12 @@ proof can distinguish a populated disk-usage tab from an empty fixture.
manager address, leader state, engine version, platform, resource capacity,
labels, and engine labels under the owning Docker host or Swarm cluster
identity.
+ Docker container network membership also extends the relationship contract:
+ `internal/unifiedresources/registry.go` must emit host-scoped
+ `attached_to` edges from runtime containers to reported Docker networks,
+ preserving network name and reported IPv4/IPv6 attachment metadata on the
+ relationship instead of requiring frontend consumers to reconstruct topology
+ from raw container facets.
Swarm secret and config records are metadata projections only. They may
preserve id, name, labels, driver/template metadata, and timestamps, but
Docker secret/config payload bytes are outside the unified-resource contract.
diff --git a/frontend-modern/src/features/docker/DockerContainersTable.tsx b/frontend-modern/src/features/docker/DockerContainersTable.tsx
index f8bbe1ce40..31acd5356b 100644
--- a/frontend-modern/src/features/docker/DockerContainersTable.tsx
+++ b/frontend-modern/src/features/docker/DockerContainersTable.tsx
@@ -39,37 +39,16 @@ import {
} from './DockerNativeTableShared';
import {
compareDockerContainers,
+ dockerContainerPortsSummary,
filterDockerResources,
mapDockerContainerStatus,
type DockerResourceStatusFilter,
} from './dockerPageModel';
import type { Resource } from '@/types/resource';
-type DockerPort = NonNullable<NonNullable<Resource['docker']>['ports']>[number];
type DockerNetwork = NonNullable<NonNullable<Resource['docker']>['networks']>[number];
type DockerMount = NonNullable<NonNullable<Resource['docker']>['mounts']>[number];
-const numberSearchValue = (value: number | undefined): string | undefined =>
- typeof value === 'number' ? String(value) : undefined;
-
-const portLabel = (port: DockerPort): string => {
- const protocol = asTrimmedString(port.protocol)?.toLowerCase() || 'tcp';
- const privatePort = numberSearchValue(port.privatePort);
- const publicPort = numberSearchValue(port.publicPort);
- const ip = asTrimmedString(port.ip);
-
- if (privatePort && publicPort) {
- return `${ip ? `${ip}:` : ''}${publicPort}->${privatePort}/${protocol}`;
- }
-
- if (privatePort) return `${privatePort}/${protocol}`;
- if (publicPort) return `${ip ? `${ip}:` : ''}${publicPort}/${protocol}`;
- return protocol;
-};
-
-const portsSummary = (resource: Resource): string =>
- dockerJoinValues(resource.docker?.ports?.map((port) => portLabel(port)));
-
const networkLabel = (network: DockerNetwork): string => {
const name = asTrimmedString(network.name);
const address = asTrimmedString(network.ipv4) || asTrimmedString(network.ipv6);
@@ -286,7 +265,7 @@ export const DockerContainersTable: Component<DockerNativeTableProps> = (props)
const health = () => dockerTextValue(resource.docker?.health);
const runtime = () => runtimeSummary(resource);
const host = () => dockerHostName(resource);
- const ports = () => portsSummary(resource);
+ const ports = () => dockerContainerPortsSummary(resource);
const networks = () => networksSummary(resource);
const mounts = () => mountsSummary(resource);
const updates = () => updateStatusLabel(resource);
@@ -306,73 +285,73 @@ export const DockerContainersTable: Component<DockerNativeTableProps> = (props)
tabIndex={0}
>
<DockerResourceNameCell resource={resource} indicator={indicator} />
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- <span class="block max-w-full truncate" title={host()}>
- {host()}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- <span class="block max-w-full truncate" title={runtime()}>
- {runtime()}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span class="block max-w-full truncate" title={image()}>
- {image()}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- {state()}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- {health()}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- {dockerNumberValue(resource.docker?.restartCount)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- <span
- class="block max-w-full truncate font-mono text-[11px]"
- title={ports()}
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
>
- {ports()}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- <span class="block max-w-full truncate" title={networks()}>
- {networks()}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- <span class="block max-w-full truncate" title={mounts()}>
- {mounts()}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span class="block max-w-full truncate" title={updateTitle()}>
- {updates()}
- </span>
- </TableCell>
+ <span class="block max-w-full truncate" title={host()}>
+ {host()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span class="block max-w-full truncate" title={runtime()}>
+ {runtime()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span class="block max-w-full truncate" title={image()}>
+ {image()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ {state()}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ {health()}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
+ >
+ {dockerNumberValue(resource.docker?.restartCount)}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span
+ class="block max-w-full truncate font-mono text-[11px]"
+ title={ports()}
+ >
+ {ports()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span class="block max-w-full truncate" title={networks()}>
+ {networks()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span class="block max-w-full truncate" title={mounts()}>
+ {mounts()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span class="block max-w-full truncate" title={updateTitle()}>
+ {updates()}
+ </span>
+ </TableCell>
</TableRow>
<PlatformResourceDetailTableRow
resource={resource}
diff --git a/frontend-modern/src/features/docker/DockerNetworksTable.tsx b/frontend-modern/src/features/docker/DockerNetworksTable.tsx
index a5ab0d27fb..5a7243cb2e 100644
--- a/frontend-modern/src/features/docker/DockerNetworksTable.tsx
+++ b/frontend-modern/src/features/docker/DockerNetworksTable.tsx
@@ -1,4 +1,5 @@
-import { For, Show, type Component } from 'solid-js';
+import { For, Show, createMemo, type Component } from 'solid-js';
+import { StatusDot } from '@/components/shared/StatusDot';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
import {
@@ -20,6 +21,11 @@ import {
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
} from '@/features/platformPage/sharedPlatformPage';
+import {
+ createPlatformResourceDetailState,
+ getPlatformResourceDetailRowClass,
+} from '@/features/platformPage/PlatformResourceDetailTableRow';
+import type { StatusIndicator } from '@/utils/status';
import {
DockerResourceNameCell,
dockerHostName,
@@ -27,9 +33,19 @@ import {
dockerTextValue,
type DockerNativeTableProps,
} from './DockerNativeTableShared';
-import { filterDockerResources, type DockerResourceStatusFilter } from './dockerPageModel';
+import {
+ buildDockerNetworkAttachmentRows,
+ dockerResourceSearchHaystack,
+ filterDockerResources,
+ type DockerNetworkAttachmentRow,
+ type DockerResourceStatusFilter,
+} from './dockerPageModel';
import type { Resource } from '@/types/resource';
+type DockerNetworksTableProps = DockerNativeTableProps & {
+ relatedResources?: Resource[];
+};
+
const networkFlags = (resource: Resource): string =>
dockerJoinValues(
[
@@ -57,12 +73,138 @@ const networkSubnets = (resource: Resource): string =>
),
);
-export const DockerNetworksTable: Component<DockerNativeTableProps> = (props) => {
+const attachmentCountLabel = (count: number): string =>
+ `${count} attached ${count === 1 ? 'container' : 'containers'}`;
+
+const attachmentSummary = (rows: readonly DockerNetworkAttachmentRow[]): string => {
+ if (rows.length === 0) return 'No containers';
+ const labels = rows.slice(0, 3).map((row) => {
+ if (row.address && row.address !== '—') return `${row.name} ${row.address}`;
+ return row.name;
+ });
+ const suffix = rows.length > labels.length ? ` +${rows.length - labels.length}` : '';
+ return `${attachmentCountLabel(rows.length)} · ${labels.join(', ')}${suffix}`;
+};
+
+const attachmentAttention = (rows: readonly DockerNetworkAttachmentRow[]): StatusIndicator => {
+ if (rows.length === 0) return { variant: 'muted', label: 'Unused' };
+ const danger = rows.filter((row) => row.status.variant === 'danger').length;
+ if (danger > 0) {
+ return { variant: 'danger', label: `${danger} needs attention` };
+ }
+ const warning = rows.filter((row) => row.status.variant === 'warning').length;
+ if (warning > 0) {
+ return { variant: 'warning', label: `${warning} warning` };
+ }
+ const running = rows.filter((row) => row.status.variant === 'success').length;
+ if (running === rows.length) {
+ return { variant: 'success', label: `${running} running` };
+ }
+ return { variant: 'muted', label: attachmentCountLabel(rows.length) };
+};
+
+const networkDetailRows = (resource: Resource) => [
+ ['Driver', dockerTextValue(resource.docker?.driver)],
+ ['Scope', dockerTextValue(resource.docker?.scope)],
+ ['Addressing', networkAddressing(resource)],
+ ['Flags', networkFlags(resource)],
+ ['Subnets', networkSubnets(resource)],
+ ['Network ID', dockerTextValue(resource.docker?.networkId)],
+];
+
+const AttachmentDetail: Component<{ rows: readonly DockerNetworkAttachmentRow[] }> = (props) => (
+ <section class="min-w-0">
+ <div class="mb-2 flex items-center justify-between gap-2">
+ <h3 class="text-xs font-semibold text-base-content">Attached containers</h3>
+ <span class="text-[11px] text-muted">{attachmentCountLabel(props.rows.length)}</span>
+ </div>
+ <Show
+ when={props.rows.length > 0}
+ fallback={
+ <div class="rounded border border-border bg-surface px-3 py-2 text-[11px] text-muted">
+ No attached Docker containers reported on this network.
+ </div>
+ }
+ >
+ <div class="space-y-1.5">
+ <For each={props.rows}>
+ {(row) => (
+ <div class="rounded border border-border bg-surface px-3 py-2">
+ <div class="grid gap-2 text-[11px] md:grid-cols-[minmax(0,1.2fr)_7rem_9rem_minmax(0,1fr)] md:items-center">
+ <div class="flex min-w-0 items-center gap-2">
+ <StatusDot size="sm" variant={row.status.variant} title={row.status.label} />
+ <span class="truncate font-semibold text-base-content" title={row.name}>
+ {row.name}
+ </span>
+ </div>
+ <span class="text-base-content">{row.status.label}</span>
+ <span class="font-mono text-base-content" title={row.address}>
+ {row.address}
+ </span>
+ <span class="truncate font-mono text-muted" title={row.ports}>
+ {row.ports}
+ </span>
+ </div>
+ <div class="mt-1 truncate text-[10px] text-muted" title={row.image}>
+ {row.image}
+ </div>
+ </div>
+ )}
+ </For>
+ </div>
+ </Show>
+ </section>
+);
+
+const NetworkConfigDetail: Component<{ resource: Resource }> = (props) => (
+ <section class="min-w-0">
+ <h3 class="mb-2 text-xs font-semibold text-base-content">Network details</h3>
+ <div class="rounded border border-border bg-surface px-3 py-2">
+ <For each={networkDetailRows(props.resource)}>
+ {([label, value]) => (
+ <div class="grid grid-cols-[6rem_minmax(0,1fr)] gap-3 py-1 text-[11px]">
+ <span class="text-muted">{label}</span>
+ <span class="truncate text-base-content" title={value}>
+ {value}
+ </span>
+ </div>
+ )}
+ </For>
+ </div>
+ </section>
+);
+
+export const DockerNetworksTable: Component<DockerNetworksTableProps> = (props) => {
+ const allResources = () => props.relatedResources ?? props.resources;
+ const attachmentsByNetwork = createMemo(() => {
+ const rows = new Map<string, DockerNetworkAttachmentRow[]>();
+ for (const network of props.resources) {
+ rows.set(network.id, buildDockerNetworkAttachmentRows(network, allResources()));
+ }
+ return rows;
+ });
+ const networkAttachments = (resource: Resource): readonly DockerNetworkAttachmentRow[] =>
+ attachmentsByNetwork().get(resource.id) ?? [];
+
+ const filterNetworks = (
+ resources: Resource[],
+ search: string,
+ status: DockerResourceStatusFilter,
+ ): Resource[] => {
+ const needle = search.trim().toLowerCase();
+ return filterDockerResources(resources, '', status).filter((resource) => {
+ if (!needle) return true;
+ if (dockerResourceSearchHaystack(resource).includes(needle)) return true;
+ return networkAttachments(resource).some((row) => row.searchText.includes(needle));
+ });
+ };
+
const tableState = createPlatformTableFilterState({
resources: () => props.resources,
initialStatus: 'all' as DockerResourceStatusFilter,
- filter: filterDockerResources,
+ filter: filterNetworks,
});
+ const drawer = createPlatformResourceDetailState({ idPrefix: 'docker-network-drawer' });
return (
<Show
@@ -102,33 +244,30 @@ export const DockerNetworksTable: Component<DockerNativeTableProps> = (props) =>
>
<TableCard class={PLATFORM_TABLE_CARD_CLASS}>
<TableCardHeader title={props.title ?? 'Networks'} />
- <Table class="min-w-full table-fixed text-xs md:min-w-[1160px]">
+ <Table class="min-w-[850px] table-fixed text-xs md:min-w-[1320px]">
<TableHeader>
<TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[20%]`}>
+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} w-[220px]`}>
Network
</TableHead>
- <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[12%]`}>
- Driver
+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} w-[360px]`}>
+ Attached workloads
+ </TableHead>
+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} w-[150px]`}>
+ Attention
</TableHead>
<TableHead
- class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[10%]`}
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[300px]`}
>
- Scope
- </TableHead>
- <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[12%]`}>
- Addressing
- </TableHead>
- <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[16%]`}>
- Flags
+ Subnets
</TableHead>
<TableHead
- class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[20%]`}
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[140px]`}
>
- Subnets
+ Driver
</TableHead>
<TableHead
- class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[10%]`}
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[140px]`}
>
Host
</TableHead>
@@ -136,51 +275,88 @@ export const DockerNetworksTable: Component<DockerNativeTableProps> = (props) =>
</TableHeader>
<TableBody class={PLATFORM_TABLE_BODY_CLASS}>
<For each={tableState.filtered()}>
- {(resource) => (
- <TableRow class="text-[11px] sm:text-xs" data-docker-network-row={resource.id}>
- <DockerResourceNameCell resource={resource} />
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- {dockerTextValue(resource.docker?.driver)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- {dockerTextValue(resource.docker?.scope)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- {networkAddressing(resource)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span
- class="inline-block max-w-[12rem] truncate"
- title={networkFlags(resource)}
- >
- {networkFlags(resource)}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- <span
- class="inline-block max-w-[18rem] truncate"
- title={networkSubnets(resource)}
+ {(resource) => {
+ const detailRowId = () => drawer.detailRowId(resource);
+ const isExpanded = () => drawer.isExpanded(resource);
+ const attachments = () => networkAttachments(resource);
+ const attention = () => attachmentAttention(attachments());
+ const subnets = () => networkSubnets(resource);
+
+ return (
+ <>
+ <TableRow
+ class={`${getPlatformResourceDetailRowClass(isExpanded())} text-[11px] sm:text-xs`}
+ aria-controls={isExpanded() ? detailRowId() : undefined}
+ aria-expanded={isExpanded() ? 'true' : 'false'}
+ data-docker-network-row={resource.id}
+ onClick={() => drawer.toggle(resource)}
+ onKeyDown={drawer.handleActivationKey(resource)}
+ tabIndex={0}
>
- {networkSubnets(resource)}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- {dockerHostName(resource)}
- </TableCell>
- </TableRow>
- )}
+ <DockerResourceNameCell resource={resource} />
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span
+ class="block max-w-full truncate"
+ title={attachmentSummary(attachments())}
+ >
+ {attachmentSummary(attachments())}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span class="inline-flex max-w-full items-center gap-1.5 truncate">
+ <StatusDot
+ size="sm"
+ variant={attention().variant}
+ title={attention().label}
+ ariaHidden
+ />
+ <span class="truncate" title={attention().label}>
+ {attention().label}
+ </span>
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span class="inline-block max-w-[18rem] truncate" title={subnets()}>
+ {subnets()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ {dockerTextValue(resource.docker?.driver)}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ {dockerHostName(resource)}
+ </TableCell>
+ </TableRow>
+ <Show when={isExpanded()}>
+ <TableRow data-docker-network-detail-row={resource.id}>
+ <TableCell
+ id={detailRowId()}
+ colspan={6}
+ class="border-b border-border bg-surface-alt p-0"
+ >
+ <div
+ class="grid gap-4 px-2 py-3 sm:px-4 sm:py-4 lg:grid-cols-[minmax(0,1fr)_minmax(16rem,24rem)]"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <AttachmentDetail rows={attachments()} />
+ <NetworkConfigDetail resource={resource} />
+ </div>
+ </TableCell>
+ </TableRow>
+ </Show>
+ </>
+ );
+ }}
</For>
</TableBody>
</Table>
diff --git a/frontend-modern/src/features/docker/DockerPageSurface.tsx b/frontend-modern/src/features/docker/DockerPageSurface.tsx
index 9a602cbf51..bebcc3cec8 100644
--- a/frontend-modern/src/features/docker/DockerPageSurface.tsx
+++ b/frontend-modern/src/features/docker/DockerPageSurface.tsx
@@ -134,6 +134,7 @@ export function DockerPageSurface() {
<Show when={activeTab() === 'networks'}>
<DockerNetworksTable
resources={model().networks}
+ relatedResources={model().resources}
emptyIcon={dockerIcon()}
emptyTitle="No networks"
emptyDescription="Networks appear here when the container runtime reports network inventory."
diff --git a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
index acc763601e..27e9186d6e 100644
--- a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
+++ b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';
import { Route, Router } from '@solidjs/router';
import type { JSX } from 'solid-js';
import { afterEach, describe, expect, it } from 'vitest';
@@ -264,24 +264,26 @@ describe('Docker native tables', () => {
});
it('renders Docker network API fields', () => {
+ const network = makeResource({
+ id: 'network-1',
+ type: 'docker-network',
+ name: 'frontend',
+ docker: {
+ hostname: 'edge-01',
+ hostSourceId: 'docker-host-1',
+ networkId: 'net-1',
+ driver: 'overlay',
+ scope: 'swarm',
+ enableIpv4: true,
+ attachable: true,
+ ingress: true,
+ subnets: [{ subnet: '10.88.0.0/24', gateway: '10.88.0.1' }],
+ },
+ });
+
render(() => (
<DockerNetworksTable
- resources={[
- makeResource({
- id: 'network-1',
- type: 'docker-network',
- name: 'frontend',
- docker: {
- hostname: 'edge-01',
- driver: 'overlay',
- scope: 'swarm',
- enableIpv4: true,
- attachable: true,
- ingress: true,
- subnets: [{ subnet: '10.88.0.0/24', gateway: '10.88.0.1' }],
- },
- }),
- ]}
+ resources={[network]}
emptyIcon={<span />}
emptyTitle="No networks"
emptyDescription="No networks"
@@ -289,13 +291,99 @@ describe('Docker native tables', () => {
/>
));
- expect(screen.getByText('Addressing')).toBeInTheDocument();
- expect(screen.getByText('Flags')).toBeInTheDocument();
+ expect(screen.getByText('Attached workloads')).toBeInTheDocument();
+ expect(screen.getByText('Attention')).toBeInTheDocument();
expect(screen.getByText('frontend')).toBeInTheDocument();
+ expect(screen.getByText('No containers')).toBeInTheDocument();
+ expect(screen.getByText('Unused')).toBeInTheDocument();
expect(screen.getByText('overlay')).toBeInTheDocument();
+ expect(screen.getByText('10.88.0.0/24 via 10.88.0.1')).toBeInTheDocument();
+
+ const row = document.querySelector('[data-docker-network-row="network-1"]');
+ expect(row).toHaveAttribute('aria-expanded', 'false');
+
+ fireEvent.click(row!);
+
+ expect(row).toHaveAttribute('aria-expanded', 'true');
+ expect(screen.getByText('Addressing')).toBeInTheDocument();
+ expect(screen.getByText('Flags')).toBeInTheDocument();
expect(screen.getByText('IPv4')).toBeInTheDocument();
expect(screen.getByText('attachable, ingress')).toBeInTheDocument();
- expect(screen.getByText('10.88.0.0/24 via 10.88.0.1')).toBeInTheDocument();
+ expect(screen.getByText('net-1')).toBeInTheDocument();
+ });
+
+ it('nests Docker containers attached to a network and searches attachment fields', () => {
+ const network = makeResource({
+ id: 'network-1',
+ type: 'docker-network',
+ name: 'frontend',
+ docker: {
+ hostname: 'edge-01',
+ hostSourceId: 'docker-host-1',
+ networkId: 'net-1',
+ driver: 'bridge',
+ scope: 'local',
+ enableIpv4: true,
+ subnets: [{ subnet: '10.88.0.0/24', gateway: '10.88.0.1' }],
+ },
+ });
+ const container = makeResource({
+ id: 'container-1',
+ type: 'app-container',
+ name: 'edge-web',
+ displayName: 'edge-web',
+ status: 'running',
+ relationships: [
+ {
+ sourceId: 'container-1',
+ targetId: 'network-1',
+ type: 'attached_to',
+ confidence: 1,
+ active: true,
+ discoverer: 'docker_adapter',
+ observedAt: '2026-06-03T09:00:00Z',
+ lastSeenAt: '2026-06-03T09:00:00Z',
+ },
+ ],
+ docker: {
+ hostname: 'edge-01',
+ hostSourceId: 'docker-host-1',
+ image: 'nginx:latest',
+ containerState: 'running',
+ health: 'healthy',
+ networks: [{ name: 'frontend', ipv4: '10.88.0.12' }],
+ ports: [{ ip: '0.0.0.0', publicPort: 8080, privatePort: 80, protocol: 'tcp' }],
+ },
+ });
+
+ render(() => (
+ <DockerNetworksTable
+ resources={[network]}
+ relatedResources={[network, container]}
+ emptyIcon={<span />}
+ emptyTitle="No networks"
+ emptyDescription="No networks"
+ />
+ ));
+
+ expect(screen.getByText('1 attached container · edge-web 10.88.0.12')).toBeInTheDocument();
+ expect(screen.getByText('1 running')).toBeInTheDocument();
+
+ const search = screen.getByPlaceholderText('Search networks');
+ fireEvent.input(search, { target: { value: '8080' } });
+
+ expect(document.querySelector('[data-docker-network-row="network-1"]')).not.toBeNull();
+
+ const row = document.querySelector('[data-docker-network-row="network-1"]');
+ fireEvent.click(row!);
+
+ const detail = within(document.querySelector('[data-docker-network-detail-row="network-1"]')!);
+ expect(detail.getByText('Attached containers')).toBeInTheDocument();
+ expect(detail.getByText('edge-web')).toBeInTheDocument();
+ expect(detail.getByText('Healthy')).toBeInTheDocument();
+ expect(detail.getByText('10.88.0.12')).toBeInTheDocument();
+ expect(detail.getByText('0.0.0.0:8080->80/tcp')).toBeInTheDocument();
+ expect(detail.getByText('nginx:latest')).toBeInTheDocument();
});
it('renders Docker Swarm node API fields', () => {
diff --git a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
index 164a1587d8..0583143aaf 100644
--- a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
+++ b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
@@ -4,6 +4,7 @@ import type { Resource } from '@/types/resource';
import {
DOCKER_TAB_SPECS,
buildDockerIncidentRows,
+ buildDockerNetworkAttachmentRows,
buildDockerPageModel,
compareDockerContainers,
compareDockerServices,
@@ -108,6 +109,79 @@ describe('dockerPageModel', () => {
expect(resolveDockerPageTabId('unknown')).toBe('overview');
});
+ it('builds host-scoped Docker network attachment rows from relationships and legacy network names', () => {
+ const network = makeResource({
+ id: 'network-1',
+ type: 'docker-network',
+ name: 'frontend',
+ docker: {
+ hostname: 'edge-01',
+ hostSourceId: 'docker-host-1',
+ },
+ });
+ const related = makeResource({
+ id: 'container-1',
+ type: 'app-container',
+ name: 'api',
+ displayName: 'api',
+ status: 'running',
+ relationships: [
+ {
+ sourceId: 'container-1',
+ targetId: 'network-1',
+ type: 'attached_to',
+ confidence: 1,
+ active: true,
+ discoverer: 'docker_adapter',
+ observedAt: '2026-06-03T09:00:00Z',
+ lastSeenAt: '2026-06-03T09:00:00Z',
+ },
+ ],
+ docker: {
+ hostname: 'edge-01',
+ hostSourceId: 'docker-host-1',
+ image: 'repo/api:latest',
+ containerState: 'running',
+ health: 'healthy',
+ networks: [{ name: 'frontend', ipv4: '10.88.0.12' }],
+ },
+ });
+ const fallback = makeResource({
+ id: 'container-2',
+ type: 'app-container',
+ name: 'worker',
+ displayName: 'worker',
+ status: 'running',
+ docker: {
+ hostname: 'edge-01',
+ hostSourceId: 'docker-host-1',
+ image: 'repo/worker:latest',
+ containerState: 'running',
+ networks: [{ name: 'frontend', ipv4: '10.88.0.13' }],
+ },
+ });
+ const otherHost = makeResource({
+ id: 'container-3',
+ type: 'app-container',
+ name: 'other-host-api',
+ displayName: 'other-host-api',
+ status: 'running',
+ docker: {
+ hostname: 'edge-02',
+ hostSourceId: 'docker-host-2',
+ networks: [{ name: 'frontend', ipv4: '10.99.0.12' }],
+ },
+ });
+
+ const rows = buildDockerNetworkAttachmentRows(network, [network, related, fallback, otherHost]);
+
+ expect(rows.map((row) => [row.name, row.address])).toEqual([
+ ['api', '10.88.0.12'],
+ ['worker', '10.88.0.13'],
+ ]);
+ expect(rows[0].searchText).toContain('repo/api:latest');
+ });
+
it('excludes non-Docker hosts that share the agent type', () => {
const model = buildDockerPageModel([
makeResource({
@@ -235,9 +309,7 @@ describe('dockerPageModel', () => {
]);
expect(hasDockerSwarmInventory(hostOnlyModel)).toBe(false);
- expect(getDockerPageTabSpecs(hostOnlyModel).map((tab) => tab.id)).toEqual([
- 'overview',
- ]);
+ expect(getDockerPageTabSpecs(hostOnlyModel).map((tab) => tab.id)).toEqual(['overview']);
expect(getDockerPageTabSpecs(runtimeInventoryModel).map((tab) => tab.id)).toEqual([
'overview',
'images',
@@ -245,10 +317,7 @@ describe('dockerPageModel', () => {
'networks',
]);
expect(hasDockerSwarmInventory(swarmModel)).toBe(true);
- expect(getDockerPageTabSpecs(swarmModel).map((tab) => tab.id)).toEqual([
- 'overview',
- 'swarm',
- ]);
+ expect(getDockerPageTabSpecs(swarmModel).map((tab) => tab.id)).toEqual(['overview', 'swarm']);
});
it('shows the Storage workflow tab when engine disk usage exists without volume rows', () => {
@@ -716,16 +785,18 @@ describe('dockerPageModel', () => {
});
it('still combines status and search', () => {
- expect(
- filterDockerResources(rows, 'payments-worker', 'degraded').map((r) => r.id),
- ).toEqual(['svc-payments']);
+ expect(filterDockerResources(rows, 'payments-worker', 'degraded').map((r) => r.id)).toEqual([
+ 'svc-payments',
+ ]);
expect(filterDockerResources(rows, 'payments-worker', 'online')).toEqual([]);
});
it('returns all rows for empty search and triad filters by status', () => {
- expect(filterDockerResources(rows, '', 'all').map((r) => r.id).sort()).toEqual(
- ['edge-proxy', 'redis-vol', 'svc-payments', 'web'].sort(),
- );
+ expect(
+ filterDockerResources(rows, '', 'all')
+ .map((r) => r.id)
+ .sort(),
+ ).toEqual(['edge-proxy', 'redis-vol', 'svc-payments', 'web'].sort());
expect(filterDockerResources(rows, '', 'degraded').map((r) => r.id)).toEqual([
'svc-payments',
]);
@@ -840,24 +911,24 @@ describe('dockerPageModel', () => {
]);
it('filters by severity bucket', () => {
- expect(
- filterDockerIncidents(incidents, '', 'critical').map((r) => r.resourceId),
- ).toEqual(['host-edge']);
- expect(
- filterDockerIncidents(incidents, '', 'warning').map((r) => r.resourceId),
- ).toEqual(['ctr-payments']);
+ expect(filterDockerIncidents(incidents, '', 'critical').map((r) => r.resourceId)).toEqual([
+ 'host-edge',
+ ]);
+ expect(filterDockerIncidents(incidents, '', 'warning').map((r) => r.resourceId)).toEqual([
+ 'ctr-payments',
+ ]);
});
it('matches resource name, code, summary, and host', () => {
expect(filterDockerIncidents(incidents, 'payments', 'all').map((r) => r.resourceId)).toEqual([
'ctr-payments',
]);
- expect(filterDockerIncidents(incidents, 'host_down', 'all').map((r) => r.resourceId)).toEqual([
- 'host-edge',
- ]);
- expect(filterDockerIncidents(incidents, 'engine down', 'all').map((r) => r.resourceId)).toEqual([
- 'host-edge',
- ]);
+ expect(filterDockerIncidents(incidents, 'host_down', 'all').map((r) => r.resourceId)).toEqual(
+ ['host-edge'],
+ );
+ expect(
+ filterDockerIncidents(incidents, 'engine down', 'all').map((r) => r.resourceId),
+ ).toEqual(['host-edge']);
expect(filterDockerIncidents(incidents, 'edge-01', 'all').length).toBe(2);
});
});
diff --git a/frontend-modern/src/features/docker/dockerPageModel.ts b/frontend-modern/src/features/docker/dockerPageModel.ts
index 74ab92e56e..cb9c769538 100644
--- a/frontend-modern/src/features/docker/dockerPageModel.ts
+++ b/frontend-modern/src/features/docker/dockerPageModel.ts
@@ -22,12 +22,7 @@ const DOCKER_SWARM_NODE_TYPES = new Set<ResourceType>(['docker-swarm-node']);
const DOCKER_SECRET_TYPES = new Set<ResourceType>(['docker-secret']);
const DOCKER_CONFIG_TYPES = new Set<ResourceType>(['docker-config']);
-export type DockerPageTabId =
- | 'overview'
- | 'images'
- | 'storage'
- | 'networks'
- | 'swarm';
+export type DockerPageTabId = 'overview' | 'images' | 'storage' | 'networks' | 'swarm';
export type DockerTabSpec = {
id: DockerPageTabId;
@@ -72,23 +67,19 @@ const isDockerPlatform = (resource: Resource): boolean =>
// `containerState` reasons that mean the container will not stay up on its
// own. Distinct from `exited` with exit code 0, which is just a stopped
// container, and from `restarting`, which is in-flight.
-const FATAL_CONTAINER_STATES = new Set([
- 'dead',
- 'removing',
- 'oomkilled',
-]);
+const FATAL_CONTAINER_STATES = new Set(['dead', 'removing', 'oomkilled']);
// Container states that read as deliberately stopped rather than as a
// problem. Pulse should surface these as muted, not as success or danger.
-const STOPPED_CONTAINER_STATES = new Set([
- 'created',
- 'paused',
- 'stopped',
- 'exited',
-]);
+const STOPPED_CONTAINER_STATES = new Set(['created', 'paused', 'stopped', 'exited']);
const normalizeDockerToken = (value: unknown): string =>
- typeof value === 'string' ? value.trim().toLowerCase().replace(/[\s_-]/g, '') : '';
+ typeof value === 'string'
+ ? value
+ .trim()
+ .toLowerCase()
+ .replace(/[\s_-]/g, '')
+ : '';
const dockerDisplayName = (resource: Resource): string =>
asTrimmedString(resource.displayName) ||
@@ -246,6 +237,145 @@ const dockerPortToken = (
return protocol;
};
+type DockerContainerPort = NonNullable<NonNullable<Resource['docker']>['ports']>[number];
+type DockerContainerNetwork = NonNullable<NonNullable<Resource['docker']>['networks']>[number];
+
+export type DockerNetworkAttachmentRow = {
+ id: string;
+ resource: Resource;
+ name: string;
+ networkName: string;
+ address: string;
+ image: string;
+ state: string;
+ health: string;
+ ports: string;
+ status: StatusIndicator;
+ searchText: string;
+};
+
+export const dockerContainerPortLabel = (port: DockerContainerPort): string =>
+ dockerPortToken(port);
+
+export const dockerContainerPortsSummary = (resource: Resource): string =>
+ (resource.docker?.ports ?? [])
+ .map((port) => dockerContainerPortLabel(port))
+ .filter((value) => value.trim().length > 0)
+ .join(', ') || '—';
+
+const dockerContainerNetworkAddress = (
+ network: DockerContainerNetwork | undefined,
+ relationship: NonNullable<Resource['relationships']>[number] | undefined,
+): string =>
+ asTrimmedString(network?.ipv4) ||
+ asTrimmedString(network?.ipv6) ||
+ asTrimmedString(relationship?.metadata?.ipv4) ||
+ asTrimmedString(relationship?.metadata?.ipv6) ||
+ '—';
+
+const dockerContainerNetworkName = (
+ network: DockerContainerNetwork | undefined,
+ relationship: NonNullable<Resource['relationships']>[number] | undefined,
+ fallbackName: string,
+): string =>
+ asTrimmedString(network?.name) ||
+ asTrimmedString(relationship?.metadata?.networkName) ||
+ fallbackName;
+
+const findContainerNetworkAttachment = (
+ network: Resource,
+ container: Resource,
+): DockerContainerNetwork | undefined => {
+ const networkName = asTrimmedString(network.name || network.displayName).toLowerCase();
+ if (!networkName) return undefined;
+ return container.docker?.networks?.find(
+ (attachment) => asTrimmedString(attachment.name).toLowerCase() === networkName,
+ );
+};
+
+const dockerHostScopeMatches = (network: Resource, container: Resource): boolean => {
+ const networkHostSourceId = asTrimmedString(network.docker?.hostSourceId);
+ const containerHostSourceId = asTrimmedString(container.docker?.hostSourceId);
+ if (networkHostSourceId && containerHostSourceId) {
+ return networkHostSourceId === containerHostSourceId;
+ }
+
+ const networkHostName = asTrimmedString(network.docker?.hostname);
+ const containerHostName = asTrimmedString(container.docker?.hostname);
+ return networkHostName !== '' && networkHostName === containerHostName;
+};
+
+const findDockerNetworkAttachmentRelationship = (
+ network: Resource,
+ container: Resource,
+): NonNullable<Resource['relationships']>[number] | undefined => {
+ const sourceId = asTrimmedString(container.id);
+ const targetId = asTrimmedString(network.id);
+ return [...(container.relationships ?? []), ...(network.relationships ?? [])].find(
+ (relationship) =>
+ relationship.active !== false &&
+ relationship.type === 'attached_to' &&
+ asTrimmedString(relationship.sourceId) === sourceId &&
+ asTrimmedString(relationship.targetId) === targetId,
+ );
+};
+
+export function buildDockerNetworkAttachmentRows(
+ network: Resource,
+ resources: readonly Resource[],
+): DockerNetworkAttachmentRow[] {
+ const fallbackNetworkName = asTrimmedString(network.name || network.displayName) || network.id;
+ return resources
+ .filter((resource) => DOCKER_CONTAINER_TYPES.has(resource.type) && isDockerPlatform(resource))
+ .flatMap((container): DockerNetworkAttachmentRow[] => {
+ const relationship = findDockerNetworkAttachmentRelationship(network, container);
+ const attachment = findContainerNetworkAttachment(network, container);
+ if (!relationship && (!attachment || !dockerHostScopeMatches(network, container))) {
+ return [];
+ }
+
+ const name = dockerDisplayName(container);
+ const networkName = dockerContainerNetworkName(attachment, relationship, fallbackNetworkName);
+ const address = dockerContainerNetworkAddress(attachment, relationship);
+ const image = asTrimmedString(container.docker?.image) || '—';
+ const state = asTrimmedString(container.docker?.containerState || container.status) || '—';
+ const health = asTrimmedString(container.docker?.health) || '—';
+ const ports = dockerContainerPortsSummary(container);
+ const status = mapDockerContainerStatus(container);
+ const searchText = [
+ name,
+ networkName,
+ address,
+ image,
+ state,
+ health,
+ ports,
+ container.id,
+ ...(container.tags ?? []),
+ ]
+ .filter((value): value is string => typeof value === 'string' && value.trim().length > 0)
+ .join(' ')
+ .toLowerCase();
+
+ return [
+ {
+ id: `${network.id}:${container.id}`,
+ resource: container,
+ name,
+ networkName,
+ address,
+ image,
+ state,
+ health,
+ ports,
+ status,
+ searchText,
+ },
+ ];
+ })
+ .sort((left, right) => compareDockerContainers(left.resource, right.resource));
+}
+
// Builds the lowercase search haystack a Docker page table consults when
// filtering rows. The shared platformPage helper carries only generic Resource
// fields; docker.* lookups live here so the cross-platform helper does not
@@ -422,8 +552,8 @@ const hasIncidentRollup = (resource: Resource): boolean =>
(resource.incidentCount ?? 0) > 0 ||
Boolean(
asTrimmedString(resource.incidentCode) ||
- asTrimmedString(resource.incidentSummary) ||
- asTrimmedString(resource.incidentLabel),
+ asTrimmedString(resource.incidentSummary) ||
+ asTrimmedString(resource.incidentLabel),
);
const buildDockerIncidentRow = (
@@ -581,10 +711,10 @@ export type DockerPageModel = {
export const hasDockerStorageUsageBucket = (bucket?: DockerStorageUsageMeta): boolean =>
Boolean(
bucket &&
- ((bucket.totalCount ?? 0) > 0 ||
- (bucket.activeCount ?? 0) > 0 ||
- (bucket.totalSizeBytes ?? 0) > 0 ||
- (bucket.reclaimableBytes ?? 0) > 0),
+ ((bucket.totalCount ?? 0) > 0 ||
+ (bucket.activeCount ?? 0) > 0 ||
+ (bucket.totalSizeBytes ?? 0) > 0 ||
+ (bucket.reclaimableBytes ?? 0) > 0),
);
export const hasDockerEngineStorageUsage = (host: Resource): boolean =>
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index 4f19ba4adb..842aeda221 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -247,6 +247,7 @@ export type ResourceRelationshipType =
| 'mounted_to'
| 'exposed_by'
| 'owned_by'
+ | 'attached_to'
| string;
export interface ResourceRelationship {
diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.go
index 66b4195218..aeec4b7ee1 100644
--- a/internal/unifiedresources/registry.go
+++ b/internal/unifiedresources/registry.go
@@ -16,6 +16,7 @@ import (
)
const autoMergeThreshold = 0.85
+const dockerAdapterRelationshipDiscoverer = "docker_adapter"
var defaultStaleThresholds = map[DataSource]time.Duration{
SourceProxmox: 60 * time.Second,
@@ -188,6 +189,7 @@ func (rr *ResourceRegistry) IngestSnapshot(snapshot models.StateSnapshot) {
for _, network := range dh.Networks {
rr.ingestDockerNetwork(network, dh)
}
+ rr.refreshDockerNetworkAttachmentRelationships(dh)
}
type dockerSecretCandidate struct {
@@ -1487,6 +1489,181 @@ func (rr *ResourceRegistry) ingestDockerNetwork(network models.DockerNetwork, ho
rr.ingest(SourceDocker, sourceID, resource, identity)
}
+func (rr *ResourceRegistry) refreshDockerNetworkAttachmentRelationships(host models.DockerHost) {
+ if len(host.Containers) == 0 && len(host.Networks) == 0 {
+ return
+ }
+
+ observedAt := host.LastSeen
+ if observedAt.IsZero() {
+ observedAt = time.Now().UTC()
+ }
+
+ rr.mu.Lock()
+ defer rr.mu.Unlock()
+
+ dockerSource := rr.bySource[SourceDocker]
+ networkIDByName := make(map[string]string, len(host.Networks))
+ for _, network := range host.Networks {
+ networkName := normalizeDockerNetworkName(network.Name)
+ if networkName == "" {
+ continue
+ }
+ sourceID := normalizeSourceID(dockerNetworkSourceID(host, network))
+ resourceID := dockerSource[sourceID]
+ if resourceID == "" {
+ continue
+ }
+ networkIDByName[networkName] = resourceID
+ }
+
+ relationshipsByContainer := make(map[string][]ResourceRelationship, len(host.Containers))
+ relationshipsByNetwork := make(map[string][]ResourceRelationship, len(networkIDByName))
+
+ for _, container := range host.Containers {
+ containerSourceID := normalizeSourceID(dockerContainerSourceID(host, container))
+ containerID := dockerSource[containerSourceID]
+ if containerID == "" {
+ continue
+ }
+ for _, attachment := range container.Networks {
+ networkID := networkIDByName[normalizeDockerNetworkName(attachment.Name)]
+ if networkID == "" {
+ continue
+ }
+ relationship := ResourceRelationship{
+ SourceID: containerID,
+ TargetID: networkID,
+ Type: RelAttachedTo,
+ Confidence: 1,
+ Active: true,
+ Discoverer: dockerAdapterRelationshipDiscoverer,
+ Metadata: dockerNetworkAttachmentMetadata(host, attachment),
+ }
+ relationshipsByContainer[containerID] = append(relationshipsByContainer[containerID], relationship)
+ relationshipsByNetwork[networkID] = append(relationshipsByNetwork[networkID], relationship)
+ }
+ }
+
+ for _, container := range host.Containers {
+ containerID := dockerSource[normalizeSourceID(dockerContainerSourceID(host, container))]
+ if containerID == "" {
+ continue
+ }
+ rr.setDockerNetworkAttachmentRelationshipsLocked(
+ containerID,
+ relationshipsByContainer[containerID],
+ observedAt,
+ )
+ }
+ for _, networkID := range networkIDByName {
+ rr.setDockerNetworkAttachmentRelationshipsLocked(
+ networkID,
+ relationshipsByNetwork[networkID],
+ observedAt,
+ )
+ }
+}
+
+func (rr *ResourceRegistry) setDockerNetworkAttachmentRelationshipsLocked(
+ resourceID string,
+ relationships []ResourceRelationship,
+ observedAt time.Time,
+) {
+ resource := rr.resources[resourceID]
+ if resource == nil {
+ return
+ }
+
+ existingByEdge := make(map[string]ResourceRelationship)
+ base := make([]ResourceRelationship, 0, len(resource.Relationships)+len(relationships))
+ for _, relationship := range resource.Relationships {
+ if isDockerNetworkAttachmentRelationship(relationship) {
+ existingByEdge[resourceRelationshipEdgeKey(relationship)] = relationship
+ continue
+ }
+ base = append(base, relationship)
+ }
+
+ nextDockerRelationships := make([]ResourceRelationship, 0, len(relationships))
+ seen := make(map[string]struct{}, len(relationships))
+ for _, relationship := range relationships {
+ key := resourceRelationshipEdgeKey(relationship)
+ if key == "" {
+ continue
+ }
+ if _, ok := seen[key]; ok {
+ continue
+ }
+ seen[key] = struct{}{}
+ if existing, ok := existingByEdge[key]; ok {
+ relationship.ObservedAt = existing.ObservedAt
+ relationship.LastSeenAt = existing.LastSeenAt
+ }
+ if relationship.ObservedAt.IsZero() {
+ relationship.ObservedAt = observedAt
+ }
+ if relationship.LastSeenAt.IsZero() {
+ relationship.LastSeenAt = observedAt
+ }
+ nextDockerRelationships = append(nextDockerRelationships, relationship)
+ }
+ sort.Slice(nextDockerRelationships, func(i, j int) bool {
+ left := nextDockerRelationships[i]
+ right := nextDockerRelationships[j]
+ if left.SourceID != right.SourceID {
+ return left.SourceID < right.SourceID
+ }
+ return left.TargetID < right.TargetID
+ })
+
+ resource.Relationships = append(base, nextDockerRelationships...)
+}
+
+func isDockerNetworkAttachmentRelationship(relationship ResourceRelationship) bool {
+ return relationship.Type == RelAttachedTo &&
+ strings.TrimSpace(relationship.Discoverer) == dockerAdapterRelationshipDiscoverer
+}
+
+func resourceRelationshipEdgeKey(relationship ResourceRelationship) string {
+ sourceID := CanonicalResourceID(relationship.SourceID)
+ targetID := CanonicalResourceID(relationship.TargetID)
+ if sourceID == "" || targetID == "" || relationship.Type == "" {
+ return ""
+ }
+ return strings.Join(
+ []string{sourceID, targetID, string(relationship.Type), strings.TrimSpace(relationship.Discoverer)},
+ "\x00",
+ )
+}
+
+func normalizeDockerNetworkName(name string) string {
+ return strings.TrimSpace(strings.ToLower(name))
+}
+
+func dockerNetworkAttachmentMetadata(
+ host models.DockerHost,
+ attachment models.DockerContainerNetworkLink,
+) map[string]any {
+ metadata := make(map[string]any, 5)
+ if hostSourceID := strings.TrimSpace(host.ID); hostSourceID != "" {
+ metadata["hostSourceId"] = hostSourceID
+ }
+ if hostname := strings.TrimSpace(host.Hostname); hostname != "" {
+ metadata["host"] = hostname
+ }
+ if networkName := strings.TrimSpace(attachment.Name); networkName != "" {
+ metadata["networkName"] = networkName
+ }
+ if ipv4 := strings.TrimSpace(attachment.IPv4); ipv4 != "" {
+ metadata["ipv4"] = ipv4
+ }
+ if ipv6 := strings.TrimSpace(attachment.IPv6); ipv6 != "" {
+ metadata["ipv6"] = ipv6
+ }
+ return metadata
+}
+
func (rr *ResourceRegistry) ingestDockerTask(task models.DockerTask, host models.DockerHost) {
resource, identity := resourceFromDockerTask(task, host)
parentID := ""
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index 7f7a186bcb..c37ca6f960 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -4000,6 +4000,66 @@ func TestRegistryIngestSnapshotPublishesDockerNativeInventory(t *testing.T) {
}
}
+func TestRegistryIngestSnapshotLinksDockerContainersToNetworks(t *testing.T) {
+ now := time.Date(2026, 6, 3, 9, 0, 0, 0, time.UTC)
+ rr := NewRegistry(NewMemoryStore())
+ rr.IngestSnapshot(models.StateSnapshot{
+ DockerHosts: []models.DockerHost{{
+ ID: "docker-host-1",
+ Hostname: "edge",
+ Runtime: "docker",
+ Status: "online",
+ LastSeen: now,
+ Containers: []models.DockerContainer{{
+ ID: "container-1",
+ Name: "api",
+ Image: "repo/api:latest",
+ State: "running",
+ Networks: []models.DockerContainerNetworkLink{{
+ Name: "frontend",
+ IPv4: "10.88.0.12",
+ }},
+ }},
+ Networks: []models.DockerNetwork{{
+ ID: "network-1",
+ Name: "frontend",
+ Driver: "bridge",
+ }},
+ }},
+ })
+
+ containers := rr.ListByType(ResourceTypeAppContainer)
+ networks := rr.ListByType(ResourceTypeDockerNetwork)
+ if len(containers) != 1 || len(networks) != 1 {
+ t.Fatalf("expected one container and one network, got containers=%d networks=%d", len(containers), len(networks))
+ }
+
+ container := containers[0]
+ network := networks[0]
+ assertDockerNetworkAttachment := func(resource Resource) {
+ t.Helper()
+ for _, relationship := range resource.Relationships {
+ if relationship.Type != RelAttachedTo {
+ continue
+ }
+ if relationship.SourceID != container.ID || relationship.TargetID != network.ID {
+ t.Fatalf("unexpected attachment relationship endpoints on %s: %+v", resource.ID, relationship)
+ }
+ if relationship.Discoverer != dockerAdapterRelationshipDiscoverer {
+ t.Fatalf("relationship discoverer = %q, want %q", relationship.Discoverer, dockerAdapterRelationshipDiscoverer)
+ }
+ if relationship.Metadata["networkName"] != "frontend" || relationship.Metadata["ipv4"] != "10.88.0.12" {
+ t.Fatalf("relationship metadata = %#v", relationship.Metadata)
+ }
+ return
+ }
+ t.Fatalf("expected docker network attachment relationship on %s, got %+v", resource.ID, resource.Relationships)
+ }
+
+ assertDockerNetworkAttachment(container)
+ assertDockerNetworkAttachment(network)
+}
+
// A live source must override a metric held by a stale higher-priority source.
func TestMergeMetric_LiveSourceOverridesStaleHigherPriority(t *testing.T) {
now := time.Now().UTC()
diff --git a/internal/unifiedresources/relationship_presentation.go b/internal/unifiedresources/relationship_presentation.go
index 62fe0b4971..0ca561e09f 100644
--- a/internal/unifiedresources/relationship_presentation.go
+++ b/internal/unifiedresources/relationship_presentation.go
@@ -32,6 +32,8 @@ func RelationshipTypeLabel(t RelationshipType) string {
return "Exposed by"
case RelOwnedBy:
return "Owned by"
+ case RelAttachedTo:
+ return "Attached to"
default:
raw := strings.TrimSpace(strings.ReplaceAll(string(t), "_", " "))
if raw == "" {
diff --git a/internal/unifiedresources/relationship_presentation_test.go b/internal/unifiedresources/relationship_presentation_test.go
index ef165ce7af..1b2143a621 100644
--- a/internal/unifiedresources/relationship_presentation_test.go
+++ b/internal/unifiedresources/relationship_presentation_test.go
@@ -12,6 +12,7 @@ func TestRelationshipTypeLabel(t *testing.T) {
RelMountedTo: "Mounted to",
RelExposedBy: "Exposed by",
RelOwnedBy: "Owned by",
+ RelAttachedTo: "Attached to",
RelationshipType("custom_link"): "Custom link",
RelationshipType(""): "Related to",
}
diff --git a/internal/unifiedresources/relationships.go b/internal/unifiedresources/relationships.go
index 7bc4d0d85d..9ba024f557 100644
--- a/internal/unifiedresources/relationships.go
+++ b/internal/unifiedresources/relationships.go
@@ -8,11 +8,12 @@ const parentRelationshipDiscoverer = "resource_registry"
type RelationshipType string
const (
- RelRunsOn RelationshipType = "runs_on" // e.g., container runs_on machine
- RelDependsOn RelationshipType = "depends_on" // e.g., app depends_on database
- RelMountedTo RelationshipType = "mounted_to" // e.g., volume mounted_to container
- RelExposedBy RelationshipType = "exposed_by" // e.g., container exposed_by ingress
- RelOwnedBy RelationshipType = "owned_by" // e.g., pod owned_by deployment
+ RelRunsOn RelationshipType = "runs_on" // e.g., container runs_on machine
+ RelDependsOn RelationshipType = "depends_on" // e.g., app depends_on database
+ RelMountedTo RelationshipType = "mounted_to" // e.g., volume mounted_to container
+ RelExposedBy RelationshipType = "exposed_by" // e.g., container exposed_by ingress
+ RelOwnedBy RelationshipType = "owned_by" // e.g., pod owned_by deployment
+ RelAttachedTo RelationshipType = "attached_to" // e.g., container attached_to network
)
// ResourceRelationship represents a typed relationship edge between two unified resources.