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.

Show Docker container health and uptime in the containers table

rcourtman8439dad9e5d9
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index bb84bc1597..283046b56a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2341,7 +2341,9 @@ not a replacement status card, CTA band, or page-local nested card.
for a note that explains a row's status dot: a TrueNAS service stopped while
set to start at boot says `should be running` beside its state in the State
cell, with the full sentence in the title and the drawer, not on a second
- line under the name. Text-only
+ line under the name. The Docker containers State cell likewise names what
+ the dot means (Unhealthy, Starting, Exited (139)) in one word or two with the
+ tone of the dot, instead of the raw `running`. Text-only
operational rows may use `getPlatformTableRowClass` to declare that same
shared rhythm explicitly; providers must not introduce local row-height
exceptions. Mobile truncation may rely on a full-value row
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index c67c85e27e..21ebac450c 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -768,6 +768,7 @@ Compact Coverage age cells use the existing metadata-size text and reclaim numer
34a. `frontend-modern/src/features/docker/DockerContainerLifecycleControls.tsx`
34b. `frontend-modern/src/features/docker/dockerContainerLifecycleActions.ts`
34c. `frontend-modern/src/features/docker/dockerContainerTableModel.ts`
+ 34d. `frontend-modern/src/features/docker/dockerContainerStatePresentation.ts`
35. `frontend-modern/src/features/docker/DockerImagesTable.tsx`
36. `frontend-modern/src/features/docker/DockerNativeTableShared.tsx`
37. `frontend-modern/src/features/docker/DockerNetworksTable.tsx`
@@ -5983,6 +5984,20 @@ memory bars yield the difference. Swarm services show the rollout state as
words ("Rollback started") with the raw token, message and completion time in
the title, and Swarm tasks show Started as an age with the RFC3339 stamp in
the title, matching every other platform table's time cells.
+The containers table's State cell says what `docker ps` would flag, through
+`dockerContainerStatePresentation.ts` over `mapDockerContainerStatus`, so the
+row dot and the words agree: Unhealthy and Starting for a running container's
+health check, Exited (139) for a crash, Restarting, and muted Exited or Paused
+for a container stopped on purpose, with the full sentence on hover. A health
+status only counts for a running container, because Docker keeps the last one
+on a stopped container (#1724). The State column appears when any row in view
+has one of those states, including an unhealthy running container. From the
+compact layout up an Uptime column shows the current run (none for a stopped
+container, whose leftover uptime is not time spent running), which marks a
+container that just restarted; narrower rows keep it in the drawer. The Ports
+cell drops the all-interfaces address and folds the IPv4/IPv6 pair Docker
+reports for one mapping, keeping a specific bind address; the title, drawer
+and search keep the full form.
ResourceDetailDrawer headings wrap long display names rather than ellipsising
them. Overview rows may still truncate identity; keyboard expansion exposes the
diff --git a/frontend-modern/browser-verification/0119676ea074c6a0.json b/frontend-modern/browser-verification/0119676ea074c6a0.json
new file mode 100644
index 0000000000..f28db1feaf
--- /dev/null
+++ b/frontend-modern/browser-verification/0119676ea074c6a0.json
@@ -0,0 +1,73 @@
+{
+ "version": 1,
+ "base_sha": "6fbebfd5231cb689ebf3b9eaf048f4fb59e92534",
+ "verified_at": "2026-10-05T15:48:27Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/features/docker/DockerContainersTable.tsx",
+ "frontend-modern/src/features/docker/dockerContainerStatePresentation.ts",
+ "frontend-modern/src/features/docker/dockerContainerTableModel.ts",
+ "frontend-modern/src/features/docker/dockerPageModel.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/features/docker/DockerContainersTable.tsx": "d7dcaf71cafe99d9d225ac2fbf3437f887d343c6dd5e134cf7df1b67ad53f0b5",
+ "frontend-modern/src/features/docker/dockerContainerStatePresentation.ts": "78867db71596d204a8beed458fdfa3e10aa44e92e1c5f038a8bea9bd55e5dc6e",
+ "frontend-modern/src/features/docker/dockerContainerTableModel.ts": "942a73eda0316d484ee550bd555befe356cd47fa0aadf5e497d417fea53aa985",
+ "frontend-modern/src/features/docker/dockerPageModel.ts": "23102b7c8cf30606e449770dd5d6d6eab957b23da433022f73a694a8dddb1a8c"
+ },
+ "routes": [
+ "/docker/containers"
+ ],
+ "viewports": [
+ {
+ "width": 390,
+ "height": 1400
+ },
+ {
+ "width": 430,
+ "height": 1000
+ },
+ {
+ "width": 600,
+ "height": 1000
+ },
+ {
+ "width": 800,
+ "height": 1000
+ },
+ {
+ "width": 1000,
+ "height": 900
+ },
+ {
+ "width": 1280,
+ "height": 1000
+ },
+ {
+ "width": 1440,
+ "height": 1100
+ },
+ {
+ "width": 1600,
+ "height": 1000
+ },
+ {
+ "width": 1920,
+ "height": 1000
+ }
+ ],
+ "states": [
+ "Containers on a mock estate with the API response edited so one running container fails its health check, one is still starting it (uptime 40s, 6 restarts) and one stopped container carries a stale unhealthy status; built on main after the image-name change (#2521)",
+ "State reads Unhealthy in red and Starting in amber where main showed running, Exited (139) and Exited (1) in red for crashes, muted Exited and Paused for stopped containers, Healthy or Running otherwise; the stopped container with a stale unhealthy status reads Exited, where main's dot called it unhealthy",
+ "One host in view (edge-apps-01) at 1000: main had no State column for the starting container and a Host column repeating the one host on every row; the change shows Starting, drops the Host column, and adds Uptime",
+ "Uptime appears from a 900px table: 9d, 10d, and 0m or 5m for containers that just restarted; stopped containers show a dash; the phone drawer keeps uptime (10d 15h)",
+ "Ports read 23210->8080/... instead of 0.0.0.0:23210->8080/..., the full form on hover; per-cell overflow at 1440 falls from 175px to 123px",
+ "Column sweep 390-1920 against main: State, Uptime and every header fit with no new clipping except one more truncated container name at 1000px; State fits Exited (139) on a phone (78px)",
+ "Dark mode at 1440: red and amber state text readable"
+ ],
+ "interactions": [
+ "Ran the column sweep on main (reverse-applied patch) and on the change across nine widths",
+ "Served edited /api/resources responses with the websocket held, in grouped and one-host views",
+ "Opened a container's row drawer on a 390px phone"
+ ]
+}
diff --git a/frontend-modern/src/features/docker/DockerContainersTable.tsx b/frontend-modern/src/features/docker/DockerContainersTable.tsx
index b174bf48ba..ea4640f497 100644
--- a/frontend-modern/src/features/docker/DockerContainersTable.tsx
+++ b/frontend-modern/src/features/docker/DockerContainersTable.tsx
@@ -45,6 +45,7 @@ import {
PlatformTableToolbar,
createPlatformTableFilterState,
createPlatformTableSortState,
+ formatPlatformTableUptimeValue,
getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
PlatformTableShell,
@@ -69,6 +70,7 @@ import {
} from './DockerNativeTableShared';
import {
compareDockerContainers,
+ dockerContainerPortsCompactSummary,
dockerContainerPortsSummary,
filterDockerResources,
mapDockerContainerStatus,
@@ -88,6 +90,11 @@ import type { Resource } from '@/types/resource';
import { DockerContainerLifecycleControls } from './DockerContainerLifecycleControls';
import { CONTAINER_CPU_CAPACITY_DESCRIPTION } from './dockerCpuPresentation';
import { DockerImageReferenceText } from './DockerImageReferenceText';
+import {
+ getDockerContainerStatePresentation,
+ getDockerContainerUptimeSeconds,
+ type DockerContainerStateTone,
+} from './dockerContainerStatePresentation';
type DockerNetwork = NonNullable<NonNullable<Resource['docker']>['networks']>[number];
type DockerMount = NonNullable<NonNullable<Resource['docker']>['mounts']>[number];
@@ -168,13 +175,19 @@ const toContainerWebLinkRows = (resource: Resource): WorkloadWebLinkRow[] => {
];
};
-const containerState = (resource: Resource): string =>
- dockerTextValue(resource.docker?.containerState || resource.status);
-
const isContainerRunning = (resource: Resource): boolean =>
(asTrimmedString(resource.docker?.containerState || resource.status) ?? '').toLowerCase() ===
'running';
+// Problems take the row's danger or warning tone, as the TrueNAS State cells
+// do; a stopped container reads muted and a running one plainly.
+const DOCKER_CONTAINER_STATE_TONE_CLASS: Record<DockerContainerStateTone | 'none', string> = {
+ danger: 'font-medium text-red-600 dark:text-red-300',
+ warning: 'font-medium text-amber-700 dark:text-amber-300',
+ muted: 'text-muted',
+ none: '',
+};
+
// v5 flagged crash-loopers in the restarts column; a container that restarted
// more than this many times needs an operator's eye even while "running".
const RESTART_ATTENTION_THRESHOLD = 5;
@@ -271,10 +284,10 @@ const getDockerContainerSortValue = (
}
case 'image':
return asTrimmedString(resource.docker?.image) || null;
- case 'state': {
- const state = containerState(resource);
- return state === '—' ? null : state;
- }
+ case 'state':
+ return getDockerContainerStatePresentation(resource).label;
+ case 'uptime':
+ return getDockerContainerUptimeSeconds(resource) ?? null;
case 'cpu':
return getPlatformTableFiniteMetric(resource.cpu?.current) ?? null;
case 'memory': {
@@ -416,7 +429,7 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
const sort = createPlatformTableSortState({
storageKey: 'dockerContainers',
sortKeys: DOCKER_CONTAINER_SORTABLE_COLUMN_IDS,
- descendingFirst: ['cpu', 'memory', 'restarts'],
+ descendingFirst: ['cpu', 'memory', 'restarts', 'uptime'],
});
const sortedRows = createMemo(() =>
sort.sortRows([...scopedRows()].sort(compareDockerContainers), getDockerContainerSortValue),
@@ -494,11 +507,13 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
typeof resource.docker?.restartCount === 'number' && resource.docker.restartCount > 0,
),
);
+ // A running container with a failing or starting health check needs the
+ // State column as much as a stopped one does.
const showStateColumn = createMemo(() =>
- scopedRows().some((resource) => {
- const state = asTrimmedString(resource.docker?.containerState || resource.status);
- return !!state && state.toLowerCase() !== 'running';
- }),
+ scopedRows().some((resource) => getDockerContainerStatePresentation(resource).tone !== null),
+ );
+ const showUptimeColumn = createMemo(() =>
+ scopedRows().some((resource) => getDockerContainerUptimeSeconds(resource) !== undefined),
);
const visibleColumns = createMemo(() =>
getDockerContainerVisibleColumnsForLayout(
@@ -506,7 +521,11 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
showRuntimeColumn(),
showRestartColumn(),
showStateColumn(),
- { groupedByHost: isGroupable() && groupingMode() === 'grouped' },
+ {
+ groupedByHost: isGroupable() && groupingMode() === 'grouped',
+ singleHost: hostOptions().length <= 1,
+ includeUptime: showUptimeColumn(),
+ },
),
);
const visibleColumnIds = createMemo(() => visibleColumns().map((column) => column.id));
@@ -517,7 +536,7 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
const renderContainerRow = (resource: Resource): JSX.Element => {
const indicator = mapDockerContainerStatus(resource);
const image = () => dockerTextValue(resource.docker?.image);
- const state = () => containerState(resource);
+ const state = () => getDockerContainerStatePresentation(resource);
const runtime = () => runtimeSummary(resource);
const host = () => dockerHostName(resource);
const running = () => isContainerRunning(resource);
@@ -542,6 +561,7 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
const hasMemoryMetric = () => memoryTotal() > 0 || memoryPercentOnly() !== undefined;
const restartCount = () => resource.docker?.restartCount ?? 0;
const ports = () => dockerContainerPortsSummary(resource);
+ const portsCompact = () => dockerContainerPortsCompactSummary(resource);
const networks = () => networksSummary(resource);
const mounts = () => mountsSummary(resource);
const updates = () => updateStatusLabel(resource);
@@ -591,8 +611,12 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
case 'state':
return (
<TableCell class={`${getPlatformTableCellClassForKind(column.kind)} text-base-content`}>
- <span class="block max-w-full truncate" title={state()}>
- {state()}
+ <span
+ class={`block max-w-full truncate ${DOCKER_CONTAINER_STATE_TONE_CLASS[state().tone ?? 'none']}`}
+ title={state().title}
+ data-docker-container-state={state().tone ?? 'ok'}
+ >
+ {state().label}
</span>
</TableCell>
);
@@ -645,11 +669,19 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
</Show>
</TableCell>
);
+ case 'uptime':
+ return (
+ <TableCell
+ class={`${getPlatformTableCellClassForKind(column.kind)} text-base-content tabular-nums`}
+ >
+ {formatPlatformTableUptimeValue(getDockerContainerUptimeSeconds(resource))}
+ </TableCell>
+ );
case 'ports':
return (
<TableCell class={`${getPlatformTableCellClassForKind(column.kind)} text-base-content`}>
<span class="block max-w-full truncate font-mono text-[11px]" title={ports()}>
- {ports()}
+ {portsCompact()}
</span>
</TableCell>
);
diff --git a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
index 7e884506df..b3ebeb988e 100644
--- a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
+++ b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
@@ -307,7 +307,8 @@ describe('Docker native tables', () => {
expect(screen.getByText('podman 5.2.1')).toBeInTheDocument();
expect(screen.getByText('nginx:latest')).toBeInTheDocument();
expect(screen.getByText('2')).toBeInTheDocument();
- expect(screen.getByText('0.0.0.0:8080->80/tcp')).toBeInTheDocument();
+ // The cell drops the all-interfaces address; the title keeps the full form.
+ expect(screen.getByText('8080->80/tcp')).toHaveAttribute('title', '0.0.0.0:8080->80/tcp');
expect(screen.getByText('frontend 172.18.0.2')).toBeInTheDocument();
expect(screen.getByText('volume:/usr/share/nginx/html (rw)')).toBeInTheDocument();
expect(screen.getByText('Available')).toBeInTheDocument();
@@ -885,7 +886,107 @@ describe('Docker native tables', () => {
));
expect(screen.getByText('State')).toBeInTheDocument();
- expect(screen.getByText('exited')).toBeInTheDocument();
+ expect(screen.getByText('Exited')).toBeInTheDocument();
+ });
+
+ it('shows the State column for a running container whose health check fails', () => {
+ setViewportWidth(WORKLOAD_TABLE_WIDE_LAYOUT_WIDTH);
+
+ renderInRouter(() => (
+ <DockerContainersTable
+ resources={[
+ makeResource({
+ id: 'container-1',
+ type: 'app-container',
+ name: 'edge-web',
+ status: 'running',
+ docker: { hostname: 'edge-01', containerState: 'running', health: 'healthy' },
+ }),
+ makeResource({
+ id: 'container-2',
+ type: 'app-container',
+ name: 'edge-api',
+ status: 'running',
+ docker: { hostname: 'edge-01', containerState: 'running', health: 'unhealthy' },
+ }),
+ ]}
+ emptyIcon={<span />}
+ emptyTitle="No containers"
+ emptyDescription="No containers"
+ showToolbar={false}
+ />
+ ));
+
+ expect(screen.getByText('State')).toBeInTheDocument();
+ const unhealthy = screen.getByText('Unhealthy');
+ expect(unhealthy).toHaveAttribute('data-docker-container-state', 'danger');
+ expect(unhealthy).toHaveAttribute('title', 'Running, but its health check is failing');
+ expect(screen.getByText('Healthy')).toHaveAttribute('data-docker-container-state', 'ok');
+ });
+
+ it("shows each running container's uptime and none for a stopped one", () => {
+ setViewportWidth(WORKLOAD_TABLE_WIDE_LAYOUT_WIDTH);
+
+ renderInRouter(() => (
+ <DockerContainersTable
+ resources={[
+ makeResource({
+ id: 'container-1',
+ type: 'app-container',
+ name: 'edge-web',
+ status: 'running',
+ docker: { hostname: 'edge-01', containerState: 'running', uptimeSeconds: 90_000 },
+ }),
+ makeResource({
+ id: 'container-2',
+ type: 'app-container',
+ name: 'edge-cache',
+ status: 'offline',
+ docker: {
+ hostname: 'edge-01',
+ containerState: 'exited',
+ exitCode: 1,
+ uptimeSeconds: 184_082,
+ },
+ }),
+ ]}
+ emptyIcon={<span />}
+ emptyTitle="No containers"
+ emptyDescription="No containers"
+ showToolbar={false}
+ />
+ ));
+
+ expect(screen.getByText('Uptime')).toBeInTheDocument();
+ const runningRow = document.querySelector('[data-docker-container-row="container-1"]');
+ const stoppedRow = document.querySelector('[data-docker-container-row="container-2"]');
+ expect(runningRow?.textContent).toContain('1d');
+ expect(stoppedRow?.textContent).not.toContain('2d');
+ expect(screen.getByText('Exited (1)')).toHaveAttribute('data-docker-container-state', 'danger');
+ });
+
+ it('leaves out the Uptime column when no container reports one', () => {
+ setViewportWidth(WORKLOAD_TABLE_WIDE_LAYOUT_WIDTH);
+
+ renderInRouter(() => (
+ <DockerContainersTable
+ resources={[
+ makeResource({
+ id: 'container-1',
+ type: 'app-container',
+ name: 'edge-web',
+ status: 'running',
+ docker: { hostname: 'edge-01', containerState: 'running' },
+ }),
+ ]}
+ emptyIcon={<span />}
+ emptyTitle="No containers"
+ emptyDescription="No containers"
+ showToolbar={false}
+ />
+ ));
+
+ expect(screen.queryByText('Uptime')).not.toBeInTheDocument();
});
it('renders actionable Docker container updates with native agent and container IDs', async () => {
diff --git a/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts b/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts
new file mode 100644
index 0000000000..b3604363fa
--- /dev/null
+++ b/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts
@@ -0,0 +1,124 @@
+import { describe, expect, it } from 'vitest';
+
+import type { Resource } from '@/types/resource';
+import {
+ getDockerContainerStatePresentation,
+ getDockerContainerUptimeSeconds,
+} from '../dockerContainerStatePresentation';
+
+const container = (docker: NonNullable<Resource['docker']>, status = 'online'): Resource =>
+ ({
+ id: 'app-container-1',
+ type: 'app-container',
+ name: 'web',
+ status,
+ docker,
+ }) as Resource;
+
+describe('getDockerContainerStatePresentation', () => {
+ it('reads a running container plainly and names its health check on hover', () => {
+ expect(
+ getDockerContainerStatePresentation(
+ container({ containerState: 'running', health: 'healthy' }),
+ ),
+ ).toEqual({
+ label: 'Healthy',
+ title: 'Running, and its health check is passing',
+ tone: null,
+ });
+ expect(getDockerContainerStatePresentation(container({ containerState: 'running' }))).toEqual({
+ label: 'Running',
+ title: 'Running, with no health check',
+ tone: null,
+ });
+ });
+
+ it('flags a failing or starting health check on a running container', () => {
+ expect(
+ getDockerContainerStatePresentation(
+ container({ containerState: 'running', health: 'unhealthy' }),
+ ),
+ ).toEqual({
+ label: 'Unhealthy',
+ title: 'Running, but its health check is failing',
+ tone: 'danger',
+ });
+ expect(
+ getDockerContainerStatePresentation(
+ container({ containerState: 'running', health: 'starting' }),
+ ),
+ ).toEqual({
+ label: 'Starting',
+ title: 'Running, and its health check has not passed yet',
+ tone: 'warning',
+ });
+ });
+
+ it('shows the exit code of a container that crashed, and mutes a clean stop', () => {
+ expect(
+ getDockerContainerStatePresentation(container({ containerState: 'exited', exitCode: 139 })),
+ ).toEqual({ label: 'Exited (139)', title: 'Exited with code 139', tone: 'danger' });
+ expect(
+ getDockerContainerStatePresentation(container({ containerState: 'exited', exitCode: 0 })),
+ ).toEqual({ label: 'Exited', title: 'Exited with code 0', tone: 'muted' });
+ expect(getDockerContainerStatePresentation(container({ containerState: 'paused' }))).toEqual({
+ label: 'Paused',
+ title: 'Paused',
+ tone: 'muted',
+ });
+ });
+
+ it('says what a dead container means on hover', () => {
+ expect(getDockerContainerStatePresentation(container({ containerState: 'dead' }))).toEqual({
+ label: 'Dead',
+ title: 'Docker failed to stop or remove it',
+ tone: 'danger',
+ });
+ });
+
+ it('marks a restarting container for attention', () => {
+ expect(
+ getDockerContainerStatePresentation(container({ containerState: 'restarting' })),
+ ).toEqual({ label: 'Restarting', title: 'Docker is restarting it', tone: 'warning' });
+ });
+});
+
+describe('a container whose agent reported no Docker state', () => {
+ it('reads the online resource status as running, health check and uptime included', () => {
+ expect(
+ getDockerContainerStatePresentation(container({ health: 'unhealthy' }, 'online')),
+ ).toEqual({
+ label: 'Unhealthy',
+ title: 'Running, but its health check is failing',
+ tone: 'danger',
+ });
+ expect(getDockerContainerStatePresentation(container({}, 'online'))).toEqual({
+ label: 'Running',
+ title: 'Running, with no health check',
+ tone: null,
+ });
+ expect(getDockerContainerUptimeSeconds(container({ uptimeSeconds: 120 }, 'online'))).toBe(120);
+ });
+});
+
+describe('getDockerContainerUptimeSeconds', () => {
+ it('reports the current run of a running or paused container', () => {
+ expect(
+ getDockerContainerUptimeSeconds(container({ containerState: 'running', uptimeSeconds: 8 })),
+ ).toBe(8);
+ expect(
+ getDockerContainerUptimeSeconds(container({ containerState: 'paused', uptimeSeconds: 3600 })),
+ ).toBe(3600);
+ });
+
+ it('drops the leftover uptime Docker keeps on a stopped container', () => {
+ expect(
+ getDockerContainerUptimeSeconds(
+ container({ containerState: 'exited', exitCode: 1, uptimeSeconds: 184082 }),
+ ),
+ ).toBeUndefined();
+ expect(
+ getDockerContainerUptimeSeconds(container({ containerState: 'running', uptimeSeconds: 0 })),
+ ).toBeUndefined();
+ });
+});
diff --git a/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts
index 27d9ed5829..9514086653 100644
--- a/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts
+++ b/frontend-modern/src/features/docker/__tests__/dockerContainerTableModel.test.ts
@@ -62,8 +62,13 @@ describe('dockerContainerTableModel', () => {
expect(getDockerContainerColumnWidthStyle('container', 'mobile', ids)).toEqual({
width: '30%',
});
+ // State spells out a problem ("Exited (139)", about 77px with padding), so
+ // it takes the room the memory bar did not need.
+ expect(getDockerContainerColumnWidthStyle('state', 'mobile', ids)).toEqual({
+ width: '14.5%',
+ });
expect(getDockerContainerColumnWidthStyle('memory', 'mobile', ids)).toEqual({
- width: '16%',
+ width: '13.5%',
});
});
@@ -75,6 +80,58 @@ describe('dockerContainerTableModel', () => {
).toEqual(['container', 'host', 'cpu', 'memory', 'updates', 'actions']);
});
+ it('drops the Host column when every container runs on one host', () => {
+ const ids = getDockerContainerVisibleColumnsForLayout('compact', false, true, true, {
+ singleHost: true,
+ }).map((column) => column.id);
+ expect(ids).not.toContain('host');
+ expect(ids).toContain('image');
+ });
+
+ it('gives the State words and the Uptime header room where the table shows them', () => {
+ // "Exited (139)" is about 70px at 12px and the cell pads 8px a side; the
+ // Uptime header is about 45px with 6px of padding a side. Checked at each
+ // layout's narrowest table, for grouped and single-host tables (a host per
+ // row only appears in a flat multi-host view the user chose).
+ const narrowest: [WorkloadTableLayoutMode, number][] = [
+ ['compact', 900],
+ ['wide', 1440],
+ ];
+ for (const [layoutMode, tableWidth] of narrowest) {
+ for (const includeRestarts of [false, true]) {
+ for (const hostOption of [{ groupedByHost: true }, { singleHost: true }]) {
+ const ids = getDockerContainerVisibleColumnsForLayout(
+ layoutMode,
+ false,
+ includeRestarts,
+ true,
+ hostOption,
+ ).map((column) => column.id);
+ const pixels = (columnId: 'state' | 'uptime') =>
+ (Number.parseFloat(
+ String(getDockerContainerColumnWidthStyle(columnId, layoutMode, ids).width),
+ ) /
+ 100) *
+ tableWidth;
+ expect(pixels('state')).toBeGreaterThanOrEqual(86);
+ expect(pixels('uptime')).toBeGreaterThanOrEqual(57);
+ }
+ }
+ }
+ });
+
+ it('drops uptime when no container in view reports one', () => {
+ const ids = getDockerContainerVisibleColumnsForLayout('compact', true, true, true, {
+ includeUptime: false,
+ }).map((column) => column.id);
+ expect(ids).not.toContain('uptime');
+ expect(
+ getDockerContainerVisibleColumnsForLayout('tablet', true, true, true).map(
+ (column) => column.id,
+ ),
+ ).not.toContain('uptime');
+ });
+
it('adds restarts only when the current row set has restart signal to scan', () => {
const withoutRestarts = getDockerContainerVisibleColumnsForLayout(
'compact',
@@ -118,6 +175,7 @@ describe('dockerContainerTableModel', () => {
'cpu',
'memory',
'restarts',
+ 'uptime',
'ports',
'updates',
'actions',
diff --git a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
index a49ed9ada3..52acda32a8 100644
--- a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
+++ b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
@@ -10,6 +10,7 @@ import {
compareDockerServices,
compareDockerSwarmNodes,
compareDockerTasks,
+ dockerContainerPortsCompactSummary,
dockerServiceStack,
filterDockerIncidents,
filterDockerResources,
@@ -431,6 +432,54 @@ describe('dockerPageModel', () => {
).toEqual({ variant: 'danger', label: 'Unhealthy' });
});
+ it('reads an online container without a reported Docker state as running', () => {
+ expect(
+ mapDockerContainerStatus(
+ makeResource({
+ id: 'c-online-unhealthy',
+ type: 'app-container',
+ status: 'online',
+ docker: { health: 'unhealthy' },
+ }),
+ ),
+ ).toEqual({ variant: 'danger', label: 'Unhealthy' });
+ expect(
+ mapDockerContainerStatus(
+ makeResource({ id: 'c-online', type: 'app-container', status: 'online', docker: {} }),
+ ),
+ ).toEqual({ variant: 'success', label: 'Running' });
+ });
+
+ it('ignores the health status Docker leaves on a stopped container', () => {
+ expect(
+ mapDockerContainerStatus(
+ makeResource({
+ id: 'c-exited-stale',
+ type: 'app-container',
+ docker: { containerState: 'exited', exitCode: 0, health: 'unhealthy' },
+ }),
+ ),
+ ).toEqual({ variant: 'muted', label: 'Exited' });
+ expect(
+ mapDockerContainerStatus(
+ makeResource({
+ id: 'c-exited-crash',
+ type: 'app-container',
+ docker: { containerState: 'exited', exitCode: 1, health: 'unhealthy' },
+ }),
+ ),
+ ).toEqual({ variant: 'danger', label: 'Exited (1)' });
+ expect(
+ mapDockerContainerStatus(
+ makeResource({
+ id: 'c-paused-stale',
+ type: 'app-container',
+ docker: { containerState: 'paused', health: 'unhealthy' },
+ }),
+ ),
+ ).toEqual({ variant: 'muted', label: 'Paused' });
+ });
+
it('flags exited containers with non-zero exit codes as danger', () => {
expect(
mapDockerContainerStatus(
@@ -1061,3 +1110,31 @@ describe('dockerPageModel', () => {
});
});
});
+
+describe('dockerContainerPortsCompactSummary', () => {
+ it('drops the all-interfaces address and folds the IPv4 and IPv6 pair', () => {
+ const resource = makeResource({
+ id: 'c-ports',
+ type: 'app-container',
+ docker: {
+ ports: [
+ { ip: '0.0.0.0', publicPort: 23210, privatePort: 8080, protocol: 'tcp' },
+ { ip: '::', publicPort: 23210, privatePort: 8080, protocol: 'tcp' },
+ { ip: '127.0.0.1', publicPort: 5432, privatePort: 5432, protocol: 'tcp' },
+ { privatePort: 9000, protocol: 'udp' },
+ ],
+ },
+ });
+ expect(dockerContainerPortsCompactSummary(resource)).toBe(
+ '23210->8080/tcp, 127.0.0.1:5432->5432/tcp, 9000/udp',
+ );
+ });
+
+ it('reads a dash when nothing is published or exposed', () => {
+ expect(
+ dockerContainerPortsCompactSummary(
+ makeResource({ id: 'c-none', type: 'app-container', docker: {} }),
+ ),
+ ).toBe('—');
+ });
+});
diff --git a/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts b/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts
new file mode 100644
index 0000000000..2602966ac6
--- /dev/null
+++ b/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts
@@ -0,0 +1,63 @@
+import type { Resource } from '@/types/resource';
+import { asTrimmedString } from '@/utils/stringUtils';
+
+import { dockerContainerRunState, mapDockerContainerStatus } from './dockerPageModel';
+
+// The State column says what `docker ps` would flag beside the status: a
+// failing or starting health check, a non-zero exit code, a restart. It reuses
+// the row's status-dot verdict so the dot and the words never disagree. Only a
+// problem or a stopped container carries a tone; a running one reads plainly.
+export type DockerContainerStateTone = 'danger' | 'warning' | 'muted';
+
+export interface DockerContainerStatePresentation {
+ label: string;
+ title: string;
+ tone: DockerContainerStateTone | null;
+}
+
+const normalizedToken = (value: unknown): string =>
+ (asTrimmedString(value) ?? '').toLowerCase().replace(/[\s_-]/g, '');
+
+const containerStateTitle = (resource: Resource, label: string): string => {
+ const state = dockerContainerRunState(resource);
+ const health = normalizedToken(resource.docker?.health);
+ const exitCode = resource.docker?.exitCode;
+ if (state === 'running') {
+ if (health === 'unhealthy') return 'Running, but its health check is failing';
+ if (health === 'starting') return 'Running, and its health check has not passed yet';
+ if (health === 'healthy') return 'Running, and its health check is passing';
+ return 'Running, with no health check';
+ }
+ if (state === 'exited' && typeof exitCode === 'number') {
+ return `Exited with code ${exitCode}`;
+ }
+ if (state === 'restarting') return 'Docker is restarting it';
+ if (state === 'oomkilled') return 'Killed after running out of memory';
+ if (state === 'dead') return 'Docker failed to stop or remove it';
+ if (state === 'removing') return 'Docker is removing it';
+ return label;
+};
+
+export const getDockerContainerStatePresentation = (
+ resource: Resource,
+): DockerContainerStatePresentation => {
+ const status = mapDockerContainerStatus(resource);
+ const tone =
+ status.variant === 'danger' || status.variant === 'warning' || status.variant === 'muted'
+ ? status.variant
+ : null;
+ return { label: status.label, title: containerStateTitle(resource, status.label), tone };
+};
+
+// Uptime is only the current run: Docker keeps the last value on a stopped
+// container, which would read as time spent running.
+const UPTIME_STATES = new Set(['running', 'paused']);
+
+export const getDockerContainerUptimeSeconds = (resource: Resource): number | undefined => {
+ const state = dockerContainerRunState(resource);
+ const seconds = resource.docker?.uptimeSeconds;
+ if (!UPTIME_STATES.has(state)) return undefined;
+ return typeof seconds === 'number' && Number.isFinite(seconds) && seconds > 0
+ ? seconds
+ : undefined;
+};
diff --git a/frontend-modern/src/features/docker/dockerContainerTableModel.ts b/frontend-modern/src/features/docker/dockerContainerTableModel.ts
index 69b1af6bee..133b7d9633 100644
--- a/frontend-modern/src/features/docker/dockerContainerTableModel.ts
+++ b/frontend-modern/src/features/docker/dockerContainerTableModel.ts
@@ -17,6 +17,7 @@ export type DockerContainerTableColumnId =
| 'cpu'
| 'memory'
| 'restarts'
+ | 'uptime'
| 'ports'
| 'networks'
| 'mounts'
@@ -41,6 +42,7 @@ export const DOCKER_CONTAINER_SORTABLE_COLUMN_IDS = [
'cpu',
'memory',
'restarts',
+ 'uptime',
'updates',
] as const satisfies readonly DockerContainerTableColumnId[];
@@ -73,6 +75,10 @@ const DOCKER_CONTAINER_COLUMN_MIN_LAYOUT: Record<
// A phone row cannot fit the Restarts header beside the Update control;
// the count stays in the row expansion there and returns at mobile width.
restarts: 'mobile',
+ // Uptime is the current run, so a short one shows a container that just
+ // restarted. Its header needs about 57px, which a tablet row cannot spare
+ // beside State, Restarts and the Update control; the drawer keeps it there.
+ uptime: 'compact',
updates: 'narrow',
actions: 'mobile',
host: 'tablet',
@@ -92,6 +98,7 @@ const DOCKER_CONTAINER_COLUMNS: DockerContainerTableColumn[] = [
{ id: 'cpu', label: 'CPU', kind: 'metric-bar' },
{ id: 'memory', label: 'Memory', kind: 'metric-bar' },
{ id: 'restarts', label: 'Restarts', kind: 'numeric-value' },
+ { id: 'uptime', label: 'Uptime', kind: 'numeric-value' },
{ id: 'ports', label: 'Ports', kind: 'text' },
{ id: 'networks', label: 'Networks', kind: 'text' },
{ id: 'mounts', label: 'Mounts', kind: 'text' },
@@ -110,18 +117,22 @@ const DOCKER_CONTAINER_COLUMNS: DockerContainerTableColumn[] = [
// menu, so every other column keeps its width. Below the 34rem phone
// container the badge wraps instead (index.css). Wide rows expand the
// lifecycle controls to about 92px, so actions gains a little there.
+// State names a problem in words ("Exited (139)", "Restarting", "Unhealthy"),
+// about 77px on a phone and 86px on desktop with padding; it takes that room
+// from the CPU and memory bars, ports and networks, which truncate anyway.
const DOCKER_CONTAINER_DESKTOP_WIDTHS: Record<DockerContainerTableColumnId, number> = {
container: 16,
host: 8,
runtime: 7,
image: 16,
- state: 6,
+ state: 7.5,
cpu: 6,
- memory: 10,
+ memory: 7,
restarts: 6,
+ uptime: 5,
ports: 10,
networks: 8,
- mounts: 9,
+ mounts: 5.5,
updates: 9,
actions: 9,
};
@@ -139,16 +150,16 @@ const DOCKER_CONTAINER_RESPONSIVE_WIDTHS: Record<
},
phone: {
container: 32,
- state: 14,
- cpu: 14,
- memory: 14,
+ state: 18,
+ cpu: 13,
+ memory: 13,
updates: 16,
},
mobile: {
container: 30,
- state: 12,
+ state: 14.5,
cpu: 10,
- memory: 16,
+ memory: 13.5,
restarts: 8,
updates: 16.25,
actions: 7.75,
@@ -156,9 +167,9 @@ const DOCKER_CONTAINER_RESPONSIVE_WIDTHS: Record<
tablet: {
container: 27,
host: 15,
- state: 10,
+ state: 14,
cpu: 9.5,
- memory: 19,
+ memory: 13,
restarts: 9,
updates: 14.5,
actions: 6,
@@ -171,12 +182,13 @@ const DOCKER_CONTAINER_RESPONSIVE_WIDTHS: Record<
host: 12,
runtime: 9.5,
image: 16.5,
- state: 7,
- cpu: 8,
- memory: 10,
+ state: 10,
+ cpu: 6.5,
+ memory: 8,
restarts: 8.5,
- ports: 12,
- updates: 13.5,
+ uptime: 7,
+ ports: 8,
+ updates: 12.5,
actions: 6,
},
};
@@ -186,15 +198,18 @@ export const getDockerContainerVisibleColumnsForLayout = (
includeRuntime: boolean,
includeRestarts: boolean,
includeState: boolean,
- options: { groupedByHost?: boolean } = {},
+ options: { groupedByHost?: boolean; singleHost?: boolean; includeUptime?: boolean } = {},
): DockerContainerTableColumn[] => {
const layoutRank = DOCKER_CONTAINER_TABLE_LAYOUT_ORDER[layoutMode];
return DOCKER_CONTAINER_COLUMNS.filter((column) => {
// Grouped by host, every row in a group shares its host and engine; the
// group header carries both instead of repeating them on each row.
if (options.groupedByHost && (column.id === 'host' || column.id === 'runtime')) return false;
+ // With one host in view the Host column would repeat its name on every row.
+ if (options.singleHost && column.id === 'host') return false;
if (column.id === 'runtime' && !includeRuntime) return false;
if (column.id === 'restarts' && !includeRestarts) return false;
+ if (column.id === 'uptime' && options.includeUptime === false) return false;
// Ultra-narrow rows still need five stable scan fields. Keep the explicit
// state label there even when every current row is running; wider layouts
// may continue to remove the otherwise repetitive column.
diff --git a/frontend-modern/src/features/docker/dockerPageModel.ts b/frontend-modern/src/features/docker/dockerPageModel.ts
index bffdfdae96..6db2579733 100644
--- a/frontend-modern/src/features/docker/dockerPageModel.ts
+++ b/frontend-modern/src/features/docker/dockerPageModel.ts
@@ -94,15 +94,27 @@ const dockerDisplayName = (resource: Resource): string =>
asTrimmedString(resource.docker?.nodeName) ||
resource.id;
-export function mapDockerContainerStatus(resource: Resource): StatusIndicator {
+// Docker's own container state, or the unified resource status when an agent
+// did not report one; "online" there means the container is running.
+export const dockerContainerRunState = (resource: Resource): string => {
const state = normalizeDockerToken(resource.docker?.containerState || resource.status);
+ return state === 'online' ? 'running' : state;
+};
+
+export function mapDockerContainerStatus(resource: Resource): StatusIndicator {
+ const state = dockerContainerRunState(resource);
const health = normalizeDockerToken(resource.docker?.health);
const exitCode = resource.docker?.exitCode;
if (FATAL_CONTAINER_STATES.has(state)) {
return { variant: 'danger', label: state === 'oomkilled' ? 'OOMKilled' : titleCase(state) };
}
- if (health === 'unhealthy') return { variant: 'danger', label: 'Unhealthy' };
+ // Docker keeps the last health status on a stopped or paused container
+ // (#1724), so a health check only speaks for a running one, or for one whose
+ // state was never reported.
+ if ((state === 'running' || !state) && health === 'unhealthy') {
+ return { variant: 'danger', label: 'Unhealthy' };
+ }
if (state === 'exited' && typeof exitCode === 'number' && exitCode !== 0) {
return { variant: 'danger', label: `Exited (${exitCode})` };
}
@@ -271,6 +283,29 @@ export const dockerContainerPortsSummary = (resource: Resource): string =>
.filter((value) => value.trim().length > 0)
.join(', ') || '—';
+// Docker prints a port published on every interface with the 0.0.0.0 (and
+// again the ::) address in front, which fills a narrow Ports cell before the
+// mapping is reached. The table cell keeps only the mapping for those, folds
+// the IPv4/IPv6 pair into one entry, and keeps a specific address such as
+// 127.0.0.1, which says who can connect. The title, drawer and search keep the
+// full form.
+const ALL_INTERFACE_PORT_ADDRESSES = new Set(['0.0.0.0', '::', '[::]']);
+
+export const dockerContainerPortsCompactSummary = (resource: Resource): string =>
+ [
+ ...new Set(
+ (resource.docker?.ports ?? [])
+ .map((port) =>
+ dockerPortToken(
+ ALL_INTERFACE_PORT_ADDRESSES.has(asTrimmedString(port.ip) ?? '')
+ ? { ...port, ip: undefined }
+ : port,
+ ),
+ )
+ .filter((value) => value.trim().length > 0),
+ ),
+ ].join(', ') || '—';
+
const dockerContainerNetworkAddress = (
network: DockerContainerNetwork | undefined,
relationship: NonNullable<Resource['relationships']>[number] | undefined,