Skip to content

Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.

TypeScript

fix(DockerService): improve volume logic and documentation in forceReinstall

Jake Turner501860a23b1f
diff --git a/admin/app/services/docker_service.ts b/admin/app/services/docker_service.ts
index d0540685..aad3927c 100644
--- a/admin/app/services/docker_service.ts
+++ b/admin/app/services/docker_service.ts
@@ -291,8 +291,12 @@ export class DockerService {
/**
* Force reinstall a service by stopping, removing, and recreating its container.
- * This method will also clear any associated volumes/data.
- * Handles edge cases gracefully (e.g., container not running, container not found).
+ *
+ * Volume handling: removes Docker-managed named volumes whose name equals
+ * `serviceName`, starts with `${serviceName}_`, or carries a `service=${serviceName}`
+ * label. Host bind mounts are NOT touched — any data living on a bind-mounted
+ * host path (ZIM stores, model caches, MySQL data dir, etc.) survives the reinstall.
+ * Anonymous volumes (random hash names) are also not matched.
*/
async forceReinstall(serviceName: string): Promise<{ success: boolean; message: string }> {
try {
@@ -365,7 +369,10 @@ export class DockerService {
const volumes = await this.docker.listVolumes()
const serviceVolumes =
volumes.Volumes?.filter(
- (v) => v.Name.includes(serviceName) || v.Labels?.service === serviceName
+ (v) =>
+ v.Name === serviceName ||
+ v.Name.startsWith(`${serviceName}_`) ||
+ v.Labels?.service === serviceName
) || []
for (const vol of serviceVolumes) {