#3513: fix(docker): add MOLTBOT_STATE_DIR to resolve permission error
docker
Cluster:
Docker Build Fixes
## Summary
- Adds `MOLTBOT_STATE_DIR=/home/node/.clawdbot` to both `moltbot-gateway` and `moltbot-cli` services in `docker-compose.yml`
- Fixes the "EACCES: permission denied" error when running Docker install
## Root Cause
When running in Docker, the app called `os.homedir()` to resolve the state directory (since `MOLTBOT_STATE_DIR` wasn't set). This returned `/home/node` based on the `HOME` env var, but the container user couldn't create nested directories properly due to volume mount permissions.
## Fix
By explicitly setting `MOLTBOT_STATE_DIR=/home/node/.clawdbot`, the app now uses this path directly instead of deriving it from `os.homedir()`, correctly matching the mounted volume path.
Fixes #3480
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the Docker onboarding path by explicitly setting `MOLTBOT_STATE_DIR=/home/node/.clawdbot` in `docker-compose.yml` for both gateway and CLI containers, and adjusts `docker-setup.sh` to `chown` the host-mounted config/workspace directories to uid/gid 1000. Together these changes aim to eliminate EACCES permission issues when the containerized app resolves its state directory (via `src/utils.ts`’s `resolveConfigDir`, which prefers `MOLTBOT_STATE_DIR`/`CLAWDBOT_STATE_DIR` over `os.homedir()`).
Main concerns are around robustness/portability: `chown -R ... 2>/dev/null || true` can hide failures and recursively changes large trees, and hard-coding `/home/node/.clawdbot` couples compose to a specific image user/home layout.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge, with minor portability/robustness caveats around Docker volume ownership and hard-coded paths.
- Changes are small and localized to Docker setup, and align with existing config-dir resolution logic (`MOLTBOT_STATE_DIR`/`CLAWDBOT_STATE_DIR`). Remaining concerns are non-fatal but could lead to confusing behavior on non-Linux hosts or when directory trees are large (silent `chown` failure; recursive ownership changes; coupling compose to `/home/node`).
- docker-setup.sh, docker-compose.yml
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#4238: Fix/docker migration atomicity
by ricardotrevisan · 2026-01-29
86.1%
#3965: Fix Docker Compose configuration for moltbot deployment
by YoByron · 2026-01-29
85.7%
#17916: [ fix ] : correct config directory path during onboarding
by Dijo-404 · 2026-02-16
84.8%
#4070: fix(docker): expose moltbot CLI in Docker image
by saianilsingi · 2026-01-29
84.1%
#11333: fix(docker): align host directory ownership with container user
by liuxiaopai-ai · 2026-02-07
83.2%
#8050: fix: docker hardening
by christopherbarnett96 · 2026-02-03
80.8%
#4695: Fixed the default CLI image to use published GHCR image
by TASMAYU · 2026-01-30
80.4%
#5458: fix: set correct file ownership in Dockerfile (#5450)
by hakyonglee · 2026-01-31
80.3%
#13737: Docker: harden UID/GID remap and docker-setup flow, convenience upd...
by ramarnat · 2026-02-10
79.3%
#9999: Docker: fix token mismatch and add dev setup workflow
by benclarkeio · 2026-02-06
79.2%