← ClaudeAtlas

docker-ephemeral-volume-fixlisted

Diagnose and fix the "settings randomly reset" pattern in Docker containers — when an app migration writes active config to a new path that isn't volume-mounted, dashboard/UI changes silently disappear on `docker compose down/up`. Includes diagnostic checklist and the copy-out-then-mount fix.
aksheyw/claude-code-learned-skills · ★ 0 · DevOps & Infrastructure · score 72
Install: claude install-skill aksheyw/claude-code-learned-skills
# Docker Ephemeral Directory Config Loss **Context:** Docker containers with app migration/rebrand that writes active config to a NEW path not covered by existing volume mounts ## Problem When a containerized app rebrands (e.g., `legacy-app` → `myapp`), the migration creates a new config directory (`.myapp/`) alongside the old one (`.legacy-app/`). If `docker-compose.yml` only mounts the OLD directory, the new one is ephemeral — any changes made via dashboard/UI/API are lost on `docker compose down && up`. **Symptoms:** - Config changes (made via dashboard or API) revert after container recreation - Settings "randomly" reset (actually on every `down/up` or `recreate`) - Migration tool logs "copying config" on every startup - Works fine after `docker compose restart` (no recreation) but breaks after `down/up` ## Root Cause Analysis ``` docker-compose.yml: volumes: - /root/.legacy-app:/root/.legacy-app # ← Mounted (persists) # /root/.myapp NOT mounted # ← Ephemeral! Startup flow: 1. Container created → .myapp/ is empty (ephemeral) 2. "Doctor" migration copies .legacy-app/ → .myapp/ 3. App runs, dashboard writes to .myapp/ (active config) 4. docker compose down → container destroyed, .myapp/ GONE 5. docker compose up → back to step 1, dashboard changes lost ``` ## Solution 1. **Copy live config from running container to host BEFORE destroying it:** ```bash mkdir -p /root/.myapp docker cp <container>:/root/.myapp/. /root/.myapp/ ``` 2.