Docker deployment: CLI resolves engine config to 127.0.0.1 — shipped iii-config.docker.yaml is never read, AGENTMEMORY_III_CONFIG is undocumented
Summary
When running the @agentmemory/agentmemory CLI inside a Docker container, the engine always ends up bound to 127.0.0.1, so published port mappings silently fail: requests from inside the container succeed, but host-mapped requests get empty responses. The config file shipped specifically for container use (iii-config.docker.yaml, bound to 0.0.0.0) is never read by any code path, and the one working escape hatch — the AGENTMEMORY_III_CONFIG env var — is undocumented.
Environment
- agentmemory 0.9.29 (npm, installed globally in the image)
- Node 24 (
node:24-bookworm-slimbase), engine = pinned iii v0.11.2 linux binary - Custom image running
node .../dist/cli.mjsas the supervisor (same layout as a native install) - Scope note: I could not test the published
iiidev/iii:0.11.2image (registry mirror refused it), so this report is scoped to containerized CLI deployments, not to the official image's own entrypoint.
What happens
findIiiConfig() in dist/cli.mjs resolves the engine config:
function findIiiConfig() {
const envPath = process.env["AGENTMEMORY_III_CONFIG"];
const candidates = [
...envPath ? [envPath] : [],
join(process.cwd(), "iii-config.yaml"),
join(homedir(), ".agentmemory", "iii-config.yaml"),
join(__dirname, "iii-config.yaml"),
join(__dirname, "..", "iii-config.yaml")
];
for (const c of candidates) if (existsSync(c)) return c;
return "";
}On boot the CLI normalizes the resolved config into $AGENTMEMORY_DATA_DIR/iii-config.yaml and rewrites engine-state.json to point there. Confirmed by experiment: a pre-seeded engine-state.json with a custom configPath gets rewritten on start, and an edited $DATA_DIR/iii-config.yaml is overwritten again on the next boot — so editing the data-dir config is not durable.
Consequences in a container:
iii-config.docker.yamlis dead weight. It (withhost: 0.0.0.0) matches none of the candidate paths. The bundleddocker-compose.ymleven mounts it at/app/config.yaml— a filename that can never be picked up byfindIiiConfig().- Resolution falls through to the bundled default (
host: 127.0.0.1). Inside a container that means the engine listens only on container loopback, soports: ["3111:3111"]mappings connect to nothing, with no error anywhere.
Evidence from the running container's /proc/net/tcp: listener at 0100007F:0C27 = 127.0.0.1:3111, while the port mapping forwards to the container's eth0 address — hence empty responses from the host side.
Workarounds (both verified working)
sedthe package-rootiii-config.yamlto0.0.0.0at image build time — it's the effective seed source (note: patching thedist/copy is not enough).- Or set
ENV AGENTMEMORY_III_CONFIG=/app/config.yaml—findIiiConfig()honors this env at top precedence (introduced around v0.9.23), pointing straight at the compose-mounted config. After this, the listener becomes00000000:0C27and host-side health checks return 200.
Suggestions
Any of the following would have saved a few hours:
- Document
AGENTMEMORY_III_CONFIGin the README (it currently has zero mentions). - Prefer the bundled
iii-config.docker.yamlwhen running in a container (/.dockerenvexists), or mention it in the docker-compose comments. - Align the docker-compose mount filename with a path
findIiiConfig()can actually resolve.
Source: rohitg00/agentmemory