openclaw - 💡(How to fix) Fix Gateway image: support mounting $HOME on a persistent volume (seed image defaults on first boot) [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70520Fetched 2026-04-24 05:57:02
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1

Root Cause

Today operators work around this with one of:

  1. Pin agents.defaults.workspace to a path inside the mounted volume (covers only the default workspace).
  2. Symlink $HOME/.openclaw/volume/.openclaw in the platform-level startup script (covers all of ~/.openclaw/* but leaves other home-dir state ephemeral, and is invisible inside the image).
  3. Move $HOME onto the volume via HOME=/volume/home — breaks because the image's preshipped $HOME contents (~/.local/bin with clawhub etc., shell profile, npm cache) aren't on the volume, so ~/.local/bin/clawhub suddenly doesn't exist at runtime. Some configs like tools.exec.pathPrepend then have to be rewritten to absolute /home/node/.local/bin paths, which is exactly what we're trying to avoid.

Fix Action

Fix / Workaround

Hit this while deploying OpenClaw gateways via a Fly.io-based "db-agent-openclaw-deployer" setup. Our current workaround symlinks ~/.openclaw/data/.openclaw at boot from the fly.toml [processes] script — works, but it's platform-specific glue that would be unnecessary if the image supported HOME-on-volume directly.

Code Example

if [ -d /opt/openclaw/home-seed ]; then
     rsync -a --ignore-existing /opt/openclaw/home-seed/ \"\$HOME/\"
   fi
RAW_BUFFERClick to expand / collapse

Problem

When OpenClaw gateway is deployed to a platform that gives the container a single persistent volume (Fly.io, Render, fly-style K8s persistent volumes, etc.), everything outside that volume is ephemeral. But meaningful agent state lives under $HOME:

  • Default agent workspace — $HOME/.openclaw/workspace/ (SOUL.md, IDENTITY.md, USER.md, MEMORY.md, memory/, HEARTBEAT.md). resolveDefaultAgentWorkspaceDir in src/agents/workspace.ts hardcodes $HOME/.openclaw/workspace regardless of OPENCLAW_STATE_DIR.
  • Potentially other ~/.openclaw/* paths, plus cache-ish state some agents/extensions may put under ~/.cache/, ~/.config/, etc.

Today operators work around this with one of:

  1. Pin agents.defaults.workspace to a path inside the mounted volume (covers only the default workspace).
  2. Symlink $HOME/.openclaw/volume/.openclaw in the platform-level startup script (covers all of ~/.openclaw/* but leaves other home-dir state ephemeral, and is invisible inside the image).
  3. Move $HOME onto the volume via HOME=/volume/home — breaks because the image's preshipped $HOME contents (~/.local/bin with clawhub etc., shell profile, npm cache) aren't on the volume, so ~/.local/bin/clawhub suddenly doesn't exist at runtime. Some configs like tools.exec.pathPrepend then have to be rewritten to absolute /home/node/.local/bin paths, which is exactly what we're trying to avoid.

The cleanest fix is at the image level. Same pattern Postgres/MySQL official images use for /var/lib/postgresql/data.

Proposal

Treat $HOME as an expected-to-be-empty persistent volume mount in the ghcr.io/openclaw/openclaw image:

  1. Move the image's baked-in user files (whatever currently lives at /home/node/*: .local/bin/*, any shell config, pre-pulled caches) to a seed location like /opt/openclaw/home-seed/.
  2. Make the entrypoint, before exec-ing the gateway, run something like:
    if [ -d /opt/openclaw/home-seed ]; then
      rsync -a --ignore-existing /opt/openclaw/home-seed/ \"\$HOME/\"
    fi
    --ignore-existing so user data on the volume always wins, seed only fills gaps.
  3. Document that operators can now mount their persistent volume directly at \$HOME (e.g. /home/node) and everything OpenClaw writes under ~/ survives restarts, with no per-path agents.defaults.workspace or symlink hacks.

Benefit

  • Deployment templates become one line: [[mounts]] destination = \"/home/node\".
  • Future state paths OpenClaw adds under ~/ persist automatically — no platform-level template changes needed.
  • Matches widely-understood Docker persistence conventions.

Context / motivation

Hit this while deploying OpenClaw gateways via a Fly.io-based "db-agent-openclaw-deployer" setup. Our current workaround symlinks ~/.openclaw/data/.openclaw at boot from the fly.toml [processes] script — works, but it's platform-specific glue that would be unnecessary if the image supported HOME-on-volume directly.

Happy to send a PR if the approach sounds right.

extent analysis

TL;DR

Modify the OpenClaw image to treat $HOME as a persistent volume mount by relocating baked-in user files and implementing a seed mechanism.

Guidance

  • Move the image's baked-in user files to a seed location like /opt/openclaw/home-seed/ to avoid overwriting user data on the volume.
  • Modify the entrypoint to run a script that synchronizes the seed location with $HOME using rsync with the --ignore-existing flag, ensuring user data on the volume takes precedence.
  • Document the new approach for operators to mount their persistent volume directly at $HOME (e.g., /home/node) for seamless persistence of OpenClaw state.
  • Test the modified image with various deployment scenarios to ensure compatibility and persistence of state.

Example

if [ -d /opt/openclaw/home-seed ]; then
  rsync -a --ignore-existing /opt/openclaw/home-seed/ "$HOME/"
fi

This script synchronizes the seed location with $HOME, ignoring existing files to prioritize user data.

Notes

The proposed solution assumes that the image's baked-in user files can be safely relocated without breaking dependencies or functionality. Additionally, the rsync command should be tested to ensure it correctly handles file permissions and ownership.

Recommendation

Apply the proposed workaround by modifying the OpenClaw image to support $HOME as a persistent volume mount, as it provides a clean and widely-understood solution for persistence.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Gateway image: support mounting $HOME on a persistent volume (seed image defaults on first boot) [1 comments, 1 participants]