Symptom#
When deploying OpenClaw using Docker, the container exits immediately after starting. Checking the logs reveals the following error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345:
starting container process caused: exec: /usr/local/bin/docker-entrypoint.sh: permission denied: unknown.
Or:
Error: ENOENT: no such file or directory, stat '/app/config/openclaw.config.js'
Root Cause Analysis#
- File Permission Issues: The
ENTRYPOINT script in the Dockerfile lacks execution permissions.
- Incorrect Mount Paths: The configuration file is not correctly mounted to the specified path inside the container.
- Improper Working Directory Setup: The working directory (
WORKDIR) of the container is not set correctly.
- Missing Environment Variables: Required environment variables are not passed in the
docker run command.
Solution#
1. Check and Fix the Dockerfile#
Ensure the Dockerfile correctly sets the entry script permissions:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
RUN chmod +x docker-entrypoint.sh
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["openclaw", "start"]
|
2. Correctly Mount Configuration Files#
1
2
3
4
5
6
7
|
docker run -d \
--name openclaw \
-p 3000:3000 \
-v $(pwd)/openclaw.config.js:/app/config/openclaw.config.js \
-v openclaw-data:/app/data \
-e NODE_ENV=production \
openclaw/openclaw:latest
|
3. Use Docker Compose (Recommended)#
Create docker-compose.yml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
version: '3.8'
services:
openclaw:
image: openclaw/openclaw:latest
container_name: openclaw
ports:
- "3000:3000"
volumes:
- ./openclaw.config.js:/app/config/openclaw.config.js
- openclaw-data:/app/data
environment:
- NODE_ENV=production
- PORT=3000
restart: unless-stopped
volumes:
openclaw-data:
|
Start the service:
4. Check Logs to Pinpoint the Issue#
1
2
3
4
5
6
7
8
|
# View container logs
docker logs openclaw
# View logs in real-time
docker logs -f openclaw
# View detailed logs
docker logs --details openclaw
|
5. Verify File Permissions Inside the Container#
1
2
3
4
5
6
7
8
|
# Enter the container for inspection
docker exec -it openclaw /bin/sh
# Check file permissions
ls -la /app/
# Check configuration files
ls -la /app/config/
|
Common Errors & Solutions#
| Error Message |
Cause |
Solution |
permission denied |
Script lacks execution permissions |
Add chmod +x in Dockerfile |
ENOENT: no such file |
Incorrect configuration file path |
Check the -v mount path |
ECONNREFUSED |
Database connection failed |
Check environment variables and network configuration |
Module not found |
Dependencies not installed |
Rebuild the image |
Verification#
After successful deployment, verify using the following commands:
1
2
3
4
5
6
7
8
|
# Check container status
docker ps | grep openclaw
# Test API endpoint
curl http://localhost:3000/api/health
# View container resource usage
docker stats openclaw
|
- Official Docker Image:
openclaw/openclaw
- Recommended to use Docker Compose for production deployments
- Regularly update the image to receive the latest security patches