mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-08 04:03:38 +00:00
fix(docker): fix volume mount path and add permission error guidance
This commit is contained in:
parent
4dac0a8930
commit
bf459c7887
@ -37,11 +37,14 @@ RUN useradd -m -u 1000 -s /bin/bash nanobot && \
|
||||
mkdir -p /home/nanobot/.nanobot && \
|
||||
chown -R nanobot:nanobot /home/nanobot /app
|
||||
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
USER nanobot
|
||||
ENV HOME=/home/nanobot
|
||||
|
||||
# Gateway default port
|
||||
EXPOSE 18790
|
||||
|
||||
ENTRYPOINT ["nanobot"]
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
CMD ["status"]
|
||||
|
||||
11
README.md
11
README.md
@ -1813,7 +1813,8 @@ print(resp.choices[0].message.content)
|
||||
## 🐳 Docker
|
||||
|
||||
> [!TIP]
|
||||
> The `-v ~/.nanobot:/root/.nanobot` flag mounts your local config directory into the container, so your config and workspace persist across container restarts.
|
||||
> The `-v ~/.nanobot:/home/nanobot/.nanobot` flag mounts your local config directory into the container, so your config and workspace persist across container restarts.
|
||||
> The container runs as user `nanobot` (UID 1000). If you get **Permission denied**, fix ownership on the host first: `sudo chown -R 1000:1000 ~/.nanobot`, or pass `--user $(id -u):$(id -g)` to match your host UID. Podman users can use `--userns=keep-id` instead.
|
||||
|
||||
### Docker Compose
|
||||
|
||||
@ -1836,17 +1837,17 @@ docker compose down # stop
|
||||
docker build -t nanobot .
|
||||
|
||||
# Initialize config (first time only)
|
||||
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot onboard
|
||||
docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot onboard
|
||||
|
||||
# Edit config on host to add API keys
|
||||
vim ~/.nanobot/config.json
|
||||
|
||||
# Run gateway (connects to enabled channels, e.g. Telegram/Discord/Mochat)
|
||||
docker run -v ~/.nanobot:/root/.nanobot -p 18790:18790 nanobot gateway
|
||||
docker run -v ~/.nanobot:/home/nanobot/.nanobot -p 18790:18790 nanobot gateway
|
||||
|
||||
# Or run a single command
|
||||
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot agent -m "Hello!"
|
||||
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot status
|
||||
docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot agent -m "Hello!"
|
||||
docker run -v ~/.nanobot:/home/nanobot/.nanobot --rm nanobot status
|
||||
```
|
||||
|
||||
## 🐧 Linux Service
|
||||
|
||||
15
entrypoint.sh
Executable file
15
entrypoint.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
dir="$HOME/.nanobot"
|
||||
if [ -d "$dir" ] && [ ! -w "$dir" ]; then
|
||||
owner_uid=$(stat -c %u "$dir" 2>/dev/null || stat -f %u "$dir" 2>/dev/null)
|
||||
cat >&2 <<EOF
|
||||
Error: $dir is not writable (owned by UID $owner_uid, running as UID $(id -u)).
|
||||
|
||||
Fix (pick one):
|
||||
Host: sudo chown -R 1000:1000 ~/.nanobot
|
||||
Docker: docker run --user \$(id -u):\$(id -g) ...
|
||||
Podman: podman run --userns=keep-id ...
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
exec nanobot "$@"
|
||||
Loading…
x
Reference in New Issue
Block a user