From 9ba26b7599b3c316e9e088d770a72b6ce8697f09 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Thu, 4 Dec 2025 19:09:23 +0100 Subject: [PATCH] feat: add DOCKER_HOST support --- app/server/core/capabilities.ts | 16 +++++++++++++--- app/server/modules/volumes/volume.service.ts | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/server/core/capabilities.ts b/app/server/core/capabilities.ts index 8860c41..14d6296 100644 --- a/app/server/core/capabilities.ts +++ b/app/server/core/capabilities.ts @@ -33,6 +33,18 @@ async function detectCapabilities(): Promise { }; } +export const parseDockerHost = (dockerHost?: string) => { + const match = dockerHost?.match(/^(ssh|http|https):\/\/([^:]+)(?::(\d+))?$/); + if (match) { + const protocol = match[1] as "ssh" | "http" | "https"; + const host = match[2]; + const port = match[3] ? parseInt(match[3], 10) : undefined; + return { protocol, host, port }; + } + + return {}; +}; + /** * Checks if Docker is available by: * 1. Checking if /var/run/docker.sock exists and is accessible @@ -40,9 +52,7 @@ async function detectCapabilities(): Promise { */ async function detectDocker(): Promise { try { - await fs.access("/var/run/docker.sock"); - - const docker = new Docker(); + const docker = new Docker(parseDockerHost(process.env.DOCKER_HOST)); await docker.ping(); logger.info("Docker capability: enabled"); diff --git a/app/server/modules/volumes/volume.service.ts b/app/server/modules/volumes/volume.service.ts index b01cefa..3f415c0 100644 --- a/app/server/modules/volumes/volume.service.ts +++ b/app/server/modules/volumes/volume.service.ts @@ -5,7 +5,7 @@ import Docker from "dockerode"; import { and, eq, ne } from "drizzle-orm"; import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced"; import slugify from "slugify"; -import { getCapabilities } from "../../core/capabilities"; +import { getCapabilities, parseDockerHost } from "../../core/capabilities"; import { db } from "../../db/db"; import { volumesTable } from "../../db/schema"; import { cryptoUtils } from "../../utils/crypto"; @@ -298,7 +298,8 @@ const getContainersUsingVolume = async (name: string) => { } try { - const docker = new Docker(); + const docker = new Docker(parseDockerHost(process.env.DOCKER_HOST)); + const containers = await docker.listContainers({ all: true }); const usingContainers = [];