Fix 'Error: EACCES: permission denied' in OpenClaw Docker (openclaw.json)
Docker permission denied? Here is the chown fix and rootless solution.
TL;DR: The Instant Fix
The Problem: OpenClaw running in Docker can't write to
openclaw.jsonor volumes due to UID mismatch. The container runs asnode(UID 1000) but files are owned byroot(UID 0).The Error:
EACCES: permission deniedwhen accessing/home/node/.openclawThe Solution:
- Quick Fix:
chownthe directory to fix permissions- Real Fix: Run container as your user (no root needed)
Deploy on Vultr (H100/A100 Ready) (High Availability & Limited Time Promotion for new accounts)
The Log: What You're Seeing
The Error:
[INFO] Starting OpenClaw...
[ERROR] Failed to write config
Error: EACCES: permission denied, mkdir '/home/node/.openclaw'
at Object.mkdirSync (node:fs:639:3)
at saveConfig (/app/dist/index.js:42:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[System] Config save failed
[Agent] Unable to initialize
Context: This error occurs when OpenClaw running in Docker tries to write configuration files or create directories but lacks permission.
Observed Behavior: Container starts but crashes when trying to save state or configuration.
Why This Happens (It's a UID Mismatch)
This is a Docker Permission Mismatch.
OpenClaw's Docker container assumes:
- Files are writable by the container user
- Volume mounts have correct ownership
- UID/GID matches between host and container
But your setup has:
- Container runs as
node(UID 1000) by default - Files owned by
root(UID 0) fromdocker execor previous runs - Volume mount with root permissions from host
The error EACCES means: "Error ACcessES denied" ā the filesystem rejected the write operation due to insufficient permissions.
Why Docker Containers Run as Root
Most Docker images run as root by default because:
- Root can do anything inside the container
- Simplifies installation (no permission issues during build)
- Traditional assumption: containers are isolated anyway
The Problem: When you docker exec into a container as root, any files created become root-owned. When OpenClaw (running as node) tries to access them later ā permission denied.
The UID Mismatch Explained
Container User: node (UID 1000)
Config File Owner: root (UID 0)
node tries to write ā File is owned by root ā EACCES: permission denied
Solution A: Fix Ownership with chown (Quick Fix)
If you've already created files with wrong ownership, fix them manually.
Step 1: Check Current Ownership
# Enter the container
docker exec -it openclaw-container sh
# Check file ownership
ls -la /home/node/.openclaw
# Output might show:
# -rw-r--r-- 1 root root 4096 Feb 4 10:23 openclaw.json
# ^^^^ ^^^^
# owned by root
Step 2: Fix Ownership
# Option 1: chown the specific file
chown node:node /home/node/.openclaw/openclaw.json
# Option 2: chown the entire directory
chown -R node:node /home/node/.openclaw
# Option 3: chown everything in home
chown -R node:node /home/node
Step 3: Fix Volume Mount Permissions
If using volume mounts, ensure correct ownership on the host:
# On your host machine
# Find the volume path
docker inspect openclaw-container | grep -A 10 Mounts
# Navigate to the volume location on host
cd /var/lib/docker/volumes/openclaw-data/_data
# Fix ownership
sudo chown -R 1000:1000 .
# Or use your exact UID/GID
id node
# uid=1000(node) gid=1000(node) groups=1000(node)
sudo chown -R 1000:1000 .
Solution B: Fix Dockerfile (Permanent Fix)
The best solution is to ensure OpenClaw runs as a non-root user from the start.
Step 1: Update Dockerfile
FROM node:18-alpine
# Install OpenClaw
RUN npm install -g openclaw
# Create non-root user
RUN addgroup -g 1000 node && \
adduser -D -u 1000 -G node -h /home/node node
# Set working directory
WORKDIR /home/node
# Create .openclaw directory with correct ownership
RUN mkdir -p /home/node/.openclaw && \
chown -R node:node /home/node/.openclaw
# Switch to non-root user
USER node
# OpenClaw config goes here
ENV OPENCLAW_CONFIG=/home/node/.openclaw/openclaw.json
CMD ["openclaw"]
Step 2: Rebuild Container
# Build new image
docker build -t openclaw:fixed .
# Stop old container
docker stop openclaw-container
docker rm openclaw-container
# Run with correct user
docker run -d \
--name openclaw-container \
-v openclaw-data:/home/node/.openclaw \
openclaw:fixed
Solution C: Run as Your Host User (Best for VPS)
On a VPS or your Linux machine, run the container with your UID/GID to avoid permission issues entirely.
Step 1: Find Your UID/GID
# Check your user ID
id
# Output: uid=1000(youruser) gid=1000(youruser) groups=1000(youruser)
Step 2: Run Container with Your User
# Run container with your UID/GID
docker run -d \
--name openclaw-container \
--user $(id -u):$(id -g) \
-v $(pwd)/openclaw-data:/home/node/.openclaw \
node:18-alpine \
npx openclaw start
This ensures all files created inside the container are owned by your user, not root.
Solution D: Rootless Docker (Most Secure)
For maximum security, use rootless Docker. This runs containers without root privileges at all.
Install Rootless Docker
# Ubuntu/Debian - Install docker-ce-rootless-extras package
sudo apt-get install -y docker-ce-rootless-extras
# Or use dockerd-rootless-setuptool.sh (included with modern Docker)
dockerd-rootless-setuptool.sh install
Run Rootless
# Rootless docker is just `dockerd` instead of `docker`
dockerd-rootless.sh install
# Run containers without root
docker run -d \
--name openclaw-container \
-v openclaw-data:/data \
openclaw:latest
Benefit: No root required, ever. All files are owned by your user automatically.
The "Survival" Recommendation
Stop debugging Docker permissions on your local machine.
Docker permissions on local Linux/Mac can be a nightmare. UIDs don't match, volume mounts are root-owned,
chownfeels hacky.The smart choice: Deploy on a fresh VPS where you control the environment from the start.
Local Docker vs Cloud VPS Comparison
| Issue | Local Docker | Cloud VPS (Vultr) |
|---|---|---|
| Permissions | UID mismatch, chown needed | Clean slate, your user only |
| Volume mounts | Root ownership issues | Properly configured |
| Debug time | 1-2 hours (chown, rebuild) | 0 minutes (works immediately) |
| Security | Need root for fixes | Isolated, no root needed |
| Setup Time | Hours of debugging | 2 minutes |
Deploy on Vultr (H100/A100 Ready) (High Availability & Limited Time Promotion for new accounts)
Complete Working Example
Verified Docker Configuration
FROM node:18-alpine
# Install OpenClaw
RUN npm install -g openclaw
# Create non-root user with specific UID/GID
RUN addgroup -g 1000 node && \
adduser -D -u 1000 -G node -h /home/node node
# Set up directory structure
WORKDIR /home/node
RUN mkdir -p /home/node/.openclaw && \
chown -R node:node /home/node/.openclaw
# Switch to non-root user early
USER node
# Set environment
ENV OPENCLAW_CONFIG=/home/node/.openclaw/openclaw.json
CMD ["openclaw"]
docker-compose.yml
version: '3.8'
services:
openclaw:
build: .
user: "1000:1000" # Run as UID 1000
volumes:
- ./data:/home/node/.openclaw
environment:
- OPENCLAW_CONFIG=/home/node/.openclaw/openclaw.json
restart: unless-stopped
Verify Permissions Work
# Start container
docker-compose up -d
# Enter container
docker-compose exec openclaw sh
# Check user
id
# Should show: uid=1000(node) gid=1000(node)
# Check directory
ls -la /home/node/.openclaw
# Should show: drwxr-xr-x node node ...
# Try writing
echo "test" > /home/node/.openclaw/test.txt
# Should work without EACCES
FAQ
Q: Why does Docker run as root by default?
A: Historical reasons. Root can do anything during build and runtime. Most Docker images still use root for simplicity. This causes permission issues when non-root processes (like Node running as `node`) try to write to root-owned files.
Q: I ran chown but still get EACCES?
A: Check the entire path. Each directory in the path must be writable. Use namei -d /home/node/.openclaw/openclaw.json to see permissions on each directory. Fix all of them with chown -R node:node /home/node.
Q: Can I just run Docker with --privileged flag?
A: You can, but it's a security risk. --privileged gives the container access to ALL host devices, which defeats Docker's isolation. Use non-root users instead ā it's more secure and follows best practices.
Q: What's the difference between EACCES and EPERM?
A: EACCES = "Permission denied" ā you don't have rights to access the file. EPERM = "Operation not permitted" ā the operation itself is not allowed (often due to file attributes like immutable bit). Both are permission errors, but EPERM is usually more severe.
Q: Is rootless Docker worth the setup effort?
A: For production, yes. Rootless Docker runs containers without root privileges, which is more secure. You never have to worry about containers escaping with root access. The setup is a one-time effort that pays off in security.
Related Fixes
-
Fix 'spawn npm ENOENT' in OpenClaw - Node/npm installation issues
-
Fix 'spawn EINVAL' on Windows - Windows permissions
-
Fix OpenClaw CUDA OOM Errors - VRAM optimization guide
-
Running OpenClaw with DeepSeek R1: Complete Guide - Setup and configuration
Bottom Line: Docker permission issues are a common pain.
Fix it with
chown(temporary) or run as non-root user (permanent).Deploy on Vultr (H100/A100 Ready) (High Availability & Limited Time Promotion for new accounts)
Still Stuck? Check Your Hardware
Sometimes the code is fine, but the GPU is simply refusing to cooperate. Before you waste another hour debugging, compare your specs against the Hardware Reality Table to see if you are fighting impossible physics.
Bookmark this site
New fixes are added as soon as they appear on GitHub Issues.
Browse Error Index ā