docker-ephemeral-volume-fixlisted
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.