Docker deployment: CLI resolves engine config to 127.0.0.1 — shipped iii-config.docker.yaml is never read, AGENTMEMORY_III_CONFIG is undocumented

Author: nemozhu8563Created Sep 28, 2026Updated Sep 28, 2026

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-slim base), engine = pinned iii v0.11.2 linux binary
  • Custom image running node .../dist/cli.mjs as the supervisor (same layout as a native install)
  • Scope note: I could not test the published iiidev/iii:0.11.2 image (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:

javascript
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:

  1. iii-config.docker.yaml is dead weight. It (with host: 0.0.0.0) matches none of the candidate paths. The bundled docker-compose.yml even mounts it at /app/config.yaml — a filename that can never be picked up by findIiiConfig().
  2. Resolution falls through to the bundled default (host: 127.0.0.1). Inside a container that means the engine listens only on container loopback, so ports: ["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)

  • sed the package-root iii-config.yaml to 0.0.0.0 at image build time — it's the effective seed source (note: patching the dist/ 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 becomes 00000000:0C27 and host-side health checks return 200.

Suggestions

Any of the following would have saved a few hours:

  1. Document AGENTMEMORY_III_CONFIG in the README (it currently has zero mentions).
  2. Prefer the bundled iii-config.docker.yaml when running in a container (/.dockerenv exists), or mention it in the docker-compose comments.
  3. Align the docker-compose mount filename with a path findIiiConfig() can actually resolve.