| name | Docker Dev Services Restart |
| description | Safe procedures for restarting Docker development services (PostgreSQL, ElectricSQL) after shutdown or reboot. Prevents accidental database data loss. |
Docker Dev Services Restart
After System Reboot
Run these commands in order from the project root:
cd /home/jason/Desktop/sertantai-legal
docker compose -f docker-compose.dev.yml up -d postgres
sleep 5
docker compose -f docker-compose.dev.yml up -d --no-deps electric
Then start the app servers:
sert-legal-start
sert-legal-start --docker
Restart Electric Only
When Electric is misbehaving but postgres is fine:
docker restart sertantai-legal-electric
If docker restart fails with "permission denied":
sudo reboot
Restart Electric with Config Changes
When docker-compose.dev.yml Electric config has changed (new env vars, etc.):
docker compose -f docker-compose.dev.yml up -d --no-deps electric
The --no-deps flag is critical -- without it, Docker may recreate the postgres container too, which can cause data loss.
Verify Services Are Running
docker ps --format "table {{.Names}}\t{{.Status}}" | grep legal
curl -s http://localhost:3002/v1/health
curl -s "http://localhost:3002/v1/shape?table=uk_lrt&offset=-1" | head -c 200
curl -s -X DELETE "http://localhost:3002/v1/shape?table=uk_lrt"
NEVER DO
| Command | Risk |
|---|
docker compose down -v | Destroys database volumes -- all 19k UK LRT records lost |
docker compose up -d electric (without --no-deps) | May recreate postgres container |
aa-remove-unknown | Removes AppArmor profiles for Firefox, VS Code, and all snap apps |
Data Recovery
If database data is accidentally lost:
cd /home/jason/Desktop/sertantai-legal/backend
unset DATABASE_URL
mix ash_postgres.migrate
cd /home/jason/Desktop/sertantai-legal
./scripts/nas/import-snapshot.sh
If the NAS is unavailable, see the legacy fallback in CLAUDE.md under "Legacy Data Import".