qm icon indicating copy to clipboard operation
qm copied to clipboard

docker target: core's API published on 0.0.0.0, local sandbox can't reach the daemon on Docker Desktop/macOS, and `qm sandbox build` ships no agent

Open moneymaker-coder opened this issue 22 hours ago • 0 comments

Summary

On the docker target (@yc-software/[email protected]) I hit three problems bringing a minimal local deployment up:

  1. Core's API port is published on all interfaces, even though publicUrl is loopback. The front door respects publicUrl; the service port does not.
  2. With sandbox.backend: "local" on Docker Desktop/macOS, core cannot use the mounted Docker socket, so no sandbox can ever provision.
  3. qm sandbox build produces an image without the agent, so the obvious "build an image, point sandbox.image at it" path yields a sandbox core cannot drive.

All three came out of one qm up; split them if you prefer separate issues.

Environment

  • @yc-software/[email protected] (npm), target docker, services core + auth, modelProvider unset
  • core image ghcr.io/yc-software/qm/core@sha256:988ce50907e469b3b1789488991c75d010e83829059bf945621ac742cf6a2aa4 (core runs as uid 1000, node)
  • macOS 26.5.2 (Intel), Docker Desktop 29.7.2, Node 24.22.1 inside core
  • config, trimmed:
    {
      "orgId": "local",
      "publicUrl": "http://localhost:8082",
      "target": "docker",
      "sandbox": { "backend": "local" }
    }
    

1. Core's API listens on 0.0.0.0

Steps

qm up
docker inspect -f '{{json .HostConfig.PortBindings}}' local-core
curl -m 3 http://<lan-ip>:8080/healthz      # from another host on the same network

Expected: with publicUrl pointing at loopback, every port qm up publishes is bound to loopback. That is what the public front door (8082) already does: 8082 is 127.0.0.1-only.

Actual: core's API (basePort + 0, i.e. 8080) is reachable from the LAN — http://<lan-ip>:8080/healthz returns 200. It is port 8080 specifically, not the front door.

Where: cli/src/backends/docker.js, runArgs(). The front-door line already prefixes publicBindAddress(config); the per-service line does not:

if (def.docker.hostPortOffset !== undefined) {
  args.push("-p", `${baseHostPort(ctx) + def.docker.hostPortOffset}:${def.docker.internalPort}`);
}
if (service === "core")
  args.push("-p", `${publicBindAddress(ctx.config)}${publicHostPort(ctx)}:${PUBLIC_PORT}`);

requireFrontDoorPort() already computes the loopback decision, so the helper is right there. Workaround used locally: prefix the service line with publicBindAddress(ctx.config); PortBindings then shows HostIp: 127.0.0.1 and the LAN URL stops answering (curl exit 7).

2. sandbox.backend: "local" can't reach the socket on Docker Desktop/macOS

Steps

# config: "sandbox": { "backend": "local" }
qm up
docker exec local-core id                          # uid=1000(node) gid=1000(node)
docker exec local-core ls -l /var/run/docker.sock  # srw-rw---- 1 root root   (inside the container)
ls -l /var/run/docker.sock                         # on the host: symlink to ~/.docker/run/docker.sock, <you>:staff
docker exec local-core docker version              # fails
docker logs local-core | grep -i 'docker daemon'   

Expected: with sandbox.backend: "local", core can talk to the mounted daemon and a sandbox provisions. Or, if the mounted socket is unusable, an error that names the actual mismatch (which gid the socket needs vs. which groups core has).

Actual: core is added to the socket's host gid (20, staff here), but Docker Desktop presents the socket inside containers as root:root 0660 regardless of the host file's owner and mode. Core runs as uid 1000, so it gets permission denied on /var/run/docker.sock. Consequences:

  • sandbox preflight fails (SANDBOX_BACKEND=local requires a running Docker daemon…), so no sandbox is ever created;
  • the deploy provider logs no Docker daemon is reachable from core (src/start.ts), which points at "start Docker Desktop" rather than at the group mismatch.

Where: hostDockerSocket() stats the socket on the host and returns its gid; runArgs() then adds --group-add <that gid>. The host's view of the socket is not the container's view.

Workaround used locally: --group-add 0 alongside the host gid; core then shows groups=0(root),20(dialout),1000(node), docker version reports server 29.7.2, and sandboxes provision. Suggested fix: derive the group from the socket as seen inside the container (or add gid 0 when the in-container socket is root:root), rather than from statSync() on the host path.

3. qm sandbox build produces an image with no agent

Steps

# any sandbox layer, e.g. sandbox/tools/example-tool/{tool.json,example-tool}
qm sandbox build
# header prints: qm sandbox build → local-sandbox:local
docker image inspect local-sandbox:local -f '{{json .Config.Cmd}}'
docker run --rm --entrypoint sh local-sandbox:local -c 'ls /opt/qm'

Expected: the image qm sandbox build produces is usable as the runtime sandbox image, or the docs/CLI make it clear it is a tools layer only and name what is actually needed at runtime.

Actual: the generated Dockerfile is FROM <base> + COPY tools/<dir>/<bin> /usr/local/bin/… + chmod + a PATH presence check — no agent.mjs, no CMD, so the image inherits the base image's keepalive command and has no /opt/qm/agent.mjs (ls /opt/qm → no such file). Pointing sandbox.image at that tag gives a sandbox that never serves on 8080.

For comparison, when sandbox.image is unset, qm up auto-builds <prefix>-sandbox-local:latest with a generated Dockerfile that does include the agent:

ARG BASE
FROM ${BASE}
COPY agent.mjs /opt/qm/agent.mjs
CMD ["node", "/opt/qm/agent.mjs"]

Where: cli/src/commands/sandbox.js, runSandboxBuild() (tools-only Dockerfile above); cli/src/backends/docker.js, ensureLocalSandboxImage(), which returns early when config.sandbox.image is set:

const image = localSandboxImage(config);
if (config.sandbox?.image)
    return image;          // no agent layer added

So the two paths disagree about what a "sandbox image" is, and the one the config field invites (sandbox.image) is the broken one.

Workaround used locally: leave sandbox.image unset, let qm up build the agent image, and name it to core via env.core.LOCAL_SANDBOX_IMAGE=<prefix>-sandbox-local:latest.

Notes

  • No model key is needed for any of the above; problems 1 and 2 reproduce on qm up alone.
  • If useful I can send the patch I'm carrying locally (loopback prefix + --group-add 0), but both are small enough to be applied directly.

moneymaker-coder avatar Dec 04 '26 20:12 moneymaker-coder