Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix: show remote images by name, size and date on the server Docker tab (#186)

darren228cfbf92f0e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27e2f9df..8e447d1f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,12 @@ release history; historical `agent-v*` tags are not panel releases.
### Fixed
+- The Docker tab on a server's detail page lists that server's images by
+ name and tag again, with readable sizes and dates. The agent reports
+ images as `repo_tags`, byte counts and epoch seconds, but the tab read
+ the CLI fields, so every row showed `<none>` and raw numbers. It now
+ uses the Docker page's image accessors, moved to `dockerHelpers.js`.
+
- Importing a Git repository that has a `docker-compose.yml` now deploys the
compose project — every service it declares — instead of building only its
Dockerfile, which started the web container without its database.
diff --git a/frontend/src/components/docker/ImagesTab.jsx b/frontend/src/components/docker/ImagesTab.jsx
index 4cae5802..754c746e 100644
--- a/frontend/src/components/docker/ImagesTab.jsx
+++ b/frontend/src/components/docker/ImagesTab.jsx
@@ -21,6 +21,11 @@ import { useTranslation } from 'react-i18next';
import {
useServer,
normalizeListResponse,
+ imageId,
+ imageRef,
+ imageSizeBytes,
+ imageSizeMb,
+ imageCreatedMs,
} from './dockerHelpers';
import { toastError } from '@/utils/errorMessage';
import { formatDateTime } from '@/utils/intl';
@@ -38,67 +43,6 @@ export const PullImageButton = () => {
);
};
-// The two transports describe the same image differently: `docker images`
-// hands back repository/tag as separate strings, the agent hands back
-// `repo_tags: ["nginx:latest"]` and nothing else. Every accessor below reads
-// both, because a column that silently blanks on remote hosts is worse than no
-// column at all.
-const imageId = (image) => String(image.id || image.ID || '').replace(/^sha256:/, '');
-
-const imageRef = (image) => {
- if (image.repository || image.tag) {
- return { repository: image.repository || '<none>', tag: image.tag || '<none>' };
- }
- const first = Array.isArray(image.repo_tags) ? image.repo_tags[0] : null;
- if (!first) return { repository: '<none>', tag: '<none>' };
- // A registry port ("registry:5000/app") puts a colon in the REPOSITORY
- // half, so the last colon is only the tag separator when no '/' follows it.
- const colon = first.lastIndexOf(':');
- if (colon > 0 && !first.slice(colon).includes('/')) {
- return { repository: first.slice(0, colon), tag: first.slice(colon + 1) };
- }
- return { repository: first, tag: '<none>' };
-};
-
-// Docker's CLI prints sizes in SI units ("142MB" = 142 * 10^6); the agent sends
-// a byte count. Parsed to MEGABYTES rather than bytes because this number is
-// also what the filter drawer and the chips show — "size is over 500 MB" is a
-// question you can ask, "is over 500000000" is not. The cell still renders
-// through the app's canonical formatter, so one host's images read the same way
-// as another's.
-const SIZE_MULTIPLIERS = {
- b: 1, kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12,
- kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3, tib: 1024 ** 4,
-};
-
-const imageSizeBytes = (image) => {
- const raw = image.size ?? image.Size;
- if (typeof raw === 'number') return Number.isFinite(raw) ? raw : null;
- if (typeof raw !== 'string') return null;
- const match = raw.trim().match(/^([\d.]+)\s*([a-z]+)?$/i);
- if (!match) return null;
- const amount = Number.parseFloat(match[1]);
- if (!Number.isFinite(amount)) return null;
- return amount * (SIZE_MULTIPLIERS[(match[2] || 'b').toLowerCase()] ?? 1);
-};
-
-// The number a filter rule compares against MUST be the number the cell shows,
-// or "Size is over 400 MB" matches a row whose own cell reads "392.9 MB". The
-// cell renders through the app-wide formatBytes, which is base-1024 with MB/GB
-// labels, so the rule value is mebibytes too — not docker's base-1000 MB.
-const imageSizeMb = (image) => {
- const bytes = imageSizeBytes(image);
- return bytes == null ? null : bytes / (1024 * 1024);
-};
-
-const imageCreatedMs = (image) => {
- const raw = image.created ?? image.CreatedAt ?? image.Created;
- // The agent sends epoch SECONDS, the CLI "2026-08-12 09:12:33 -0400 EDT".
- if (typeof raw === 'number') return raw > 1e11 ? raw : raw * 1000;
- const parsed = Date.parse(raw || '');
- return Number.isNaN(parsed) ? null : parsed;
-};
-
// Built-in views. Dangling is the one axis this payload really has: docker
// reports an untagged layer as repository `<none>`, on both transports, so the
// rule below is reading a fact rather than a guess. There is deliberately no
diff --git a/frontend/src/components/docker/__tests__/dockerHelpers.test.mjs b/frontend/src/components/docker/__tests__/dockerHelpers.test.mjs
new file mode 100644
index 00000000..40d4a4d3
--- /dev/null
+++ b/frontend/src/components/docker/__tests__/dockerHelpers.test.mjs
@@ -0,0 +1,56 @@
+// Proving test for the Docker image accessors shared by the Docker page and the
+// server detail Docker tab. The two transports describe the same image
+// differently: the `docker images` CLI gives repository/tag strings and sizes
+// like "142MB", the agent gives `repo_tags`, a byte count and epoch seconds.
+// Both must render the same name, tag, size and date.
+//
+// Run: node --test src/components/docker/__tests__/dockerHelpers.test.mjs
+import test from 'node:test';
+import assert from 'node:assert/strict';
+
+import { imageId, imageRef, imageSizeBytes, imageCreatedMs } from '../dockerHelpers.js';
+
+test('imageRef splits an agent repo_tags entry into repository and tag', () => {
+ assert.deepEqual(
+ imageRef({ repo_tags: ['roundcube/roundcubemail:latest-apache'] }),
+ { repository: 'roundcube/roundcubemail', tag: 'latest-apache' },
+ );
+ assert.deepEqual(
+ imageRef({ repo_tags: ['ghcr.io/docker-mailserver/docker-mailserver:16.0.1'] }),
+ { repository: 'ghcr.io/docker-mailserver/docker-mailserver', tag: '16.0.1' },
+ );
+});
+
+test('imageRef does not split on a registry port', () => {
+ assert.deepEqual(imageRef({ repo_tags: ['registry:5000/app'] }), { repository: 'registry:5000/app', tag: '<none>' });
+ assert.deepEqual(imageRef({ repo_tags: ['registry:5000/app:1.2'] }), { repository: 'registry:5000/app', tag: '1.2' });
+});
+
+test('imageRef reports an untagged image as <none>', () => {
+ assert.deepEqual(imageRef({ repo_tags: [] }), { repository: '<none>', tag: '<none>' });
+ assert.deepEqual(imageRef({}), { repository: '<none>', tag: '<none>' });
+});
+
+test('imageRef passes CLI repository/tag fields through', () => {
+ assert.deepEqual(imageRef({ repository: 'nginx', tag: 'latest' }), { repository: 'nginx', tag: 'latest' });
+});
+
+test('imageId drops the sha256: prefix', () => {
+ assert.equal(imageId({ id: 'sha256:734d9162c522' }), '734d9162c522');
+ assert.equal(imageId({ ID: '734d9162c522' }), '734d9162c522');
+});
+
+test('imageSizeBytes reads agent byte counts and CLI size strings', () => {
+ assert.equal(imageSizeBytes({ size: 1044290102 }), 1044290102);
+ assert.equal(imageSizeBytes({ size: '142MB' }), 142e6);
+ assert.equal(imageSizeBytes({ size: '1.5GB' }), 1.5e9);
+ assert.equal(imageSizeBytes({ size: 'n/a' }), null);
+ assert.equal(imageSizeBytes({}), null);
+});
+
+test('imageCreatedMs reads agent epoch seconds and CLI date strings', () => {
+ assert.equal(imageCreatedMs({ created: 1792605383 }), 1792605383000);
+ assert.equal(imageCreatedMs({ created: 1792605383000 }), 1792605383000);
+ assert.equal(imageCreatedMs({ CreatedAt: '2026-08-12T09:12:33Z' }), Date.parse('2026-08-12T09:12:33Z'));
+ assert.equal(imageCreatedMs({ created: 'not a date' }), null);
+});
diff --git a/frontend/src/components/docker/dockerHelpers.js b/frontend/src/components/docker/dockerHelpers.js
index 5c2d9ffb..d6986d72 100644
--- a/frontend/src/components/docker/dockerHelpers.js
+++ b/frontend/src/components/docker/dockerHelpers.js
@@ -106,3 +106,64 @@ export const getContainerProjectName = (container, details) => {
const labels = details?.Config?.Labels || container?.Labels || {};
return labels['com.docker.compose.project'] || labels['com.docker.compose.service'] || '-';
};
+
+// The two transports describe the same image differently: `docker images`
+// hands back repository/tag as separate strings, the agent hands back
+// `repo_tags: ["nginx:latest"]` and nothing else. Every accessor below reads
+// both, because a column that silently blanks on remote hosts is worse than no
+// column at all.
+export const imageId = (image) => String(image.id || image.ID || '').replace(/^sha256:/, '');
+
+export const imageRef = (image) => {
+ if (image.repository || image.tag) {
+ return { repository: image.repository || '<none>', tag: image.tag || '<none>' };
+ }
+ const first = Array.isArray(image.repo_tags) ? image.repo_tags[0] : null;
+ if (!first) return { repository: '<none>', tag: '<none>' };
+ // A registry port ("registry:5000/app") puts a colon in the REPOSITORY
+ // half, so the last colon is only the tag separator when no '/' follows it.
+ const colon = first.lastIndexOf(':');
+ if (colon > 0 && !first.slice(colon).includes('/')) {
+ return { repository: first.slice(0, colon), tag: first.slice(colon + 1) };
+ }
+ return { repository: first, tag: '<none>' };
+};
+
+// Docker's CLI prints sizes in SI units ("142MB" = 142 * 10^6); the agent sends
+// a byte count. Parsed to MEGABYTES rather than bytes because this number is
+// also what the filter drawer and the chips show — "size is over 500 MB" is a
+// question you can ask, "is over 500000000" is not. The cell still renders
+// through the app's canonical formatter, so one host's images read the same way
+// as another's.
+const SIZE_MULTIPLIERS = {
+ b: 1, kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12,
+ kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3, tib: 1024 ** 4,
+};
+
+export const imageSizeBytes = (image) => {
+ const raw = image.size ?? image.Size;
+ if (typeof raw === 'number') return Number.isFinite(raw) ? raw : null;
+ if (typeof raw !== 'string') return null;
+ const match = raw.trim().match(/^([\d.]+)\s*([a-z]+)?$/i);
+ if (!match) return null;
+ const amount = Number.parseFloat(match[1]);
+ if (!Number.isFinite(amount)) return null;
+ return amount * (SIZE_MULTIPLIERS[(match[2] || 'b').toLowerCase()] ?? 1);
+};
+
+// The number a filter rule compares against MUST be the number the cell shows,
+// or "Size is over 400 MB" matches a row whose own cell reads "392.9 MB". The
+// cell renders through the app-wide formatBytes, which is base-1024 with MB/GB
+// labels, so the rule value is mebibytes too — not docker's base-1000 MB.
+export const imageSizeMb = (image) => {
+ const bytes = imageSizeBytes(image);
+ return bytes == null ? null : bytes / (1024 * 1024);
+};
+
+export const imageCreatedMs = (image) => {
+ const raw = image.created ?? image.CreatedAt ?? image.Created;
+ // The agent sends epoch SECONDS, the CLI "2026-08-12 09:12:33 -0400 EDT".
+ if (typeof raw === 'number') return raw > 1e11 ? raw : raw * 1000;
+ const parsed = Date.parse(raw || '');
+ return Number.isNaN(parsed) ? null : parsed;
+};
diff --git a/frontend/src/components/serverdetail/ServerDockerTab.jsx b/frontend/src/components/serverdetail/ServerDockerTab.jsx
index 6091c6b3..e454cc2f 100644
--- a/frontend/src/components/serverdetail/ServerDockerTab.jsx
+++ b/frontend/src/components/serverdetail/ServerDockerTab.jsx
@@ -15,6 +15,10 @@ import {
TrashIcon,
} from './serverDetailShared';
import { toastError } from '@/utils/errorMessage';
+import { formatBytes } from '@/utils/formatBytes';
+import { formatRelativeTime } from '@/utils/time';
+import { formatDateTime } from '@/utils/intl';
+import { imageId, imageRef, imageSizeBytes, imageCreatedMs } from '../docker/dockerHelpers';
// The /servers/<id>/docker/* endpoints return raw arrays from Flask
// (route extracts result.get('data') before jsonify). The agent envelope's
@@ -46,15 +50,6 @@ const formatPorts = (ports) => {
return parts.join(', ');
};
-// docker prints image sizes as strings ("25.5MB", "1.2GB") — parse to bytes
-// so the Size column sorts numerically instead of lexicographically.
-const SIZE_UNITS = { b: 1, kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12 };
-const parseDockerSize = (size) => {
- const match = /^([\d.]+)\s*(b|kb|mb|gb|tb)$/i.exec(size || '');
- if (!match) return null;
- return parseFloat(match[1]) * (SIZE_UNITS[match[2].toLowerCase()] || 1);
-};
-
// Images table columns. Cell markup and classNames are identical to the
// hand-rolled table they replace so the .data-table SCSS keeps applying.
const IMAGE_COLUMNS = [
@@ -63,35 +58,43 @@ const IMAGE_COLUMNS = [
headerKey: 'app.serverDockerTab.repository', header: 'Repository',
sortable: true,
hideable: false,
- sortValue: (image) => image.repository || '<none>',
- render: (image) => image.repository || '<none>',
+ sortValue: (image) => imageRef(image).repository,
+ render: (image) => imageRef(image).repository,
},
{
key: 'tag',
headerKey: 'app.serverDockerTab.tag', header: 'Tag',
sortable: true,
- sortValue: (image) => image.tag || '<none>',
- render: (image) => image.tag || '<none>',
+ sortValue: (image) => imageRef(image).tag,
+ render: (image) => imageRef(image).tag,
},
{
key: 'id',
headerKey: 'app.serverDockerTab.imageId', header: 'Image ID',
cellClassName: 'sk-cell-mono',
- render: (image) => image.id?.substring(0, 12),
+ render: (image) => imageId(image).substring(0, 12),
},
{
key: 'size',
headerKey: 'common.labels.size', header: 'Size',
sortable: true,
- sortValue: (image) => parseDockerSize(image.size),
- render: (image) => image.size,
+ sortValue: imageSizeBytes,
+ render: (image) => formatBytes(imageSizeBytes(image)),
},
{
key: 'created',
headerKey: 'common.labels.created', header: 'Created',
sortable: true,
- sortValue: (image) => image.created || null,
- render: (image) => image.created,
+ sortValue: imageCreatedMs,
+ render: (image) => {
+ const ms = imageCreatedMs(image);
+ if (ms == null) return '-';
+ return (
+ <span title={formatDateTime(ms)}>
+ {formatRelativeTime(new Date(ms).toISOString())}
+ </span>
+ );
+ },
},
];