Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix: handle null ports in Docker container table (#5313)

Matt Van Horn1639da57794d
diff --git a/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx b/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx
index f8c8509f5..537c85e7c 100644
--- a/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx
+++ b/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx
@@ -76,6 +76,7 @@ const createColumns = (
accessorKey: "ports",
header: t("docker.field.ports.label"),
Cell({ cell }) {
+ if (!cell.row.original.ports) return null;
if (!cell.row.original.ports.length) return null;
return (
<OverflowBadge overflowCount={1} data={cell.row.original.ports.map((port) => port.PrivatePort.toString())} />
diff --git a/packages/api/src/router/docker/docker-router.ts b/packages/api/src/router/docker/docker-router.ts
index 6a0ea49a0..e5a4b4796 100644
--- a/packages/api/src/router/docker/docker-router.ts
+++ b/packages/api/src/router/docker/docker-router.ts
@@ -140,7 +140,7 @@ interface DockerContainer {
id: string;
state: ContainerState;
image: string;
- ports: Port[];
+ ports: Port[] | undefined;
iconUrl: string | null;
cpuUsage: number;
memoryUsage: number;
diff --git a/packages/modals-collection/src/docker/add-docker-app-to-homarr.tsx b/packages/modals-collection/src/docker/add-docker-app-to-homarr.tsx
index fc8567ccb..f94bf8f24 100644
--- a/packages/modals-collection/src/docker/add-docker-app-to-homarr.tsx
+++ b/packages/modals-collection/src/docker/add-docker-app-to-homarr.tsx
@@ -21,7 +21,7 @@ export const AddDockerAppToHomarrModal = createModal<AddDockerAppToHomarrProps>(
{
initialValues: {
containerUrls: innerProps.selectedContainers.map((container) => {
- if (container.ports[0]) {
+ if (Array.isArray(container.ports) && container.ports[0]) {
return `http://${container.ports[0].IP}:${container.ports[0].PublicPort}`;
}
diff --git a/packages/request-handler/src/docker.ts b/packages/request-handler/src/docker.ts
index 0d2c02809..7b873ec00 100644
--- a/packages/request-handler/src/docker.ts
+++ b/packages/request-handler/src/docker.ts
@@ -1,5 +1,6 @@
import dayjs from "dayjs";
import type { ContainerInfo, ContainerStats } from "dockerode";
+import type Dockerode from "dockerode";
import { db, like, or } from "@homarr/db";
import { icons } from "@homarr/db/schema";
@@ -72,7 +73,7 @@ async function getContainersWithStatsAsync() {
cpuUsage,
memoryUsage,
image: container.Image,
- ports: container.Ports,
+ ports: container.Ports as Dockerode.Port[] | undefined,
};
});