#6638: fix: make Dockerfile work on container platforms (Render, Railway, etc.)
docker
Cluster:
Docker and Deployment Improvements
## Summary
This PR fixes several issues that prevent the Dockerfile from working on container platforms like Render, Railway, Fly.io, etc.
### Changes
1. **Add `gateway` subcommand to CMD** - The current CMD runs `node dist/index.js` without a subcommand
2. **Add `--allow-unconfigured` flag** - Gateway refuses to start without config on first run
3. **Add `--bind lan`** - Binds to `0.0.0.0` instead of localhost (required for platform health checks)
4. **Use `${PORT:-10000}`** - Respects platform's PORT environment variable
5. **Add entrypoint script** - Enables runtime configuration from environment variables
6. **Support `OPENAI_API_KEY` env var** - Easy LLM setup without mounting config files
### Problem
The current Dockerfile doesn't work on container platforms because:
- CMD is missing the `gateway` subcommand
- Gateway refuses to start without a config file
- Gateway binds to localhost only, so platform health checks fail and containers get killed
### Testing
Successfully deployed and tested on Render with this Dockerfile. The gateway starts correctly, health checks pass, and OpenAI chat works via the Control UI.
### Environment Variables
Users can configure the gateway with these env vars:
- `OPENAI_API_KEY` - OpenAI API key for LLM
- `OPENCLAW_STATE_DIR` - State directory (default: `$HOME/.openclaw`)
- `OPENCLAW_RESET_CONFIG` - Set to `true` to reset config on restart
- `PORT` - HTTP port (default: 10000)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the container startup flow so the built `dist/index.js` is invoked with the `gateway` subcommand and flags needed for common PaaS/container platforms (bind to LAN, allow unconfigured startup, and use the platform `PORT` env var). It also adds a generated entrypoint script that creates a minimal `~/.openclaw/openclaw.json` on first run and optionally includes OpenAI configuration from `OPENAI_API_KEY`, aiming to remove the need to mount config files on first boot.
Overall this fits into existing gateway CLI behavior (`openclaw gateway run` / `node dist/index.js gateway …`) but there are a couple of container-specific gotchas around shell/runtime user home paths, secrets handling, and gateway auth requirements when binding beyond loopback.
<h3>Confidence Score: 2/5</h3>
- This PR is not safe to merge as-is because the default command path likely fails gateway auth when binding to LAN without a token/password configured.
- The Dockerfile changes are straightforward, but the entrypoint’s default `--bind lan` combined with `auth.mode=token` and no token value will cause the gateway CLI to exit. There are also portability and security concerns (bash dependency and persisting API keys in a plaintext config file).
- Dockerfile
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#12504: fix: allow docker cli container to connect to gateway
by bvanderdrift · 2026-02-09
85.5%
#8478: Security: remove --allow-unconfigured from default Dockerfile CMD
by uttej-badwane · 2026-02-04
85.2%
#9190: feat(docker): Add autonomous container self-restart and runtime pac...
by alexdredmon · 2026-02-05
83.9%
#9999: Docker: fix token mismatch and add dev setup workflow
by benclarkeio · 2026-02-06
83.8%
#21784: fix(security): restrict gateway ports to loopback by default
by smilekyra · 2026-02-20
82.3%
#8050: fix: docker hardening
by christopherbarnett96 · 2026-02-03
82.2%
#7133: feat: Automated Docker setup with environment-based configuration
by synetalsolutions · 2026-02-02
81.4%
#19644: feat(docker): add init script support via /openclaw-init.d/
by JayMishra-source · 2026-02-18
81.1%
#13539: Claude/update dockerfile cmd 1 te te
by federiconicolasvozza-oss · 2026-02-10
80.0%
#6698: feat: Add CLI wrapper for Docker integration and update documentation
by barshopen · 2026-02-01
79.3%