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 7169d6f..48dea19 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 { toMessage } from "../../utils/errors"; @@ -277,7 +277,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 = [];