Commit 68ce183
authored
Make /etc/hosts write non-fatal for non-root container execution (#3985)
## Context
Companion to [gh-aw#26658](github/gh-aw#26658),
which adds `--user $(id -u):$(id -g)` to the MCP gateway Docker run
command so log files written via `/tmp` bind mounts are readable by
downstream redaction and upload steps.
## Problem
`run_containerized.sh` runs with `set -e` and unconditionally writes to
`/etc/hosts` (line 289):
```bash
echo "$HOST_IP host.docker.internal" >> /etc/hosts
```
When the container runs as a non-root user, this write fails with
EACCES, aborting the entire gateway startup.
## Fix
Wrap the `/etc/hosts` write in an if-else so failure produces a warning
instead of aborting. With `--network host` (which the gateway always
uses), the `host.docker.internal` mapping is unnecessary since
`localhost` works directly.
## Changes
| File | Change |
|------|--------|
| `run_containerized.sh` | Make `/etc/hosts` write non-fatal; log
warning on failure |
`make agent-finished` ✓1 file changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
| |||
0 commit comments