Skip to content

feat(cli): verify Docker daemon is running and warn on occupied proof-server port#78

Open
notsoblack wants to merge 1 commit into
midnightntwrk:mainfrom
notsoblack:improve-daemon-and-port-checks
Open

feat(cli): verify Docker daemon is running and warn on occupied proof-server port#78
notsoblack wants to merge 1 commit into
midnightntwrk:mainfrom
notsoblack:improve-daemon-and-port-checks

Conversation

@notsoblack

Copy link
Copy Markdown

Summary

Improves the create-mn-app CLI's pre-flight requirement checks to catch two of the most common silent failure modes reported by developers:

  1. Docker Desktop installed but not runningdocker --version succeeds even when the daemon is down, causing confusing errors later during proof-server setup.
  2. Port 6300 already in use — Another process (or a lingering Docker container) holds the default proof-server port, resulting in an opaque Docker bind error.

What's changed

src/utils/requirement-checker.ts

  • checkDocker() now runs docker info (with a 5s timeout) after detecting the binary. If the daemon is unreachable, the check marks Docker as found: false with a warning explaining the user must start Docker Desktop.
  • checkPortAvailable(port) added — performs a lightweight net.Socket probe to 127.0.0.1:6300. If the connection succeeds, a warning is emitted so the user knows the port is occupied before scaffolding begins.
  • Imports net from Node.js stdlib (no new dependencies).

src/create-app.ts

  • Integrated await RequirementChecker.checkPortAvailable(6300) into the existing requirements block so the port check runs alongside Node, Docker, and Compact checks.

src/__tests__/requirement-checker.test.ts (new)

  • Added comprehensive unit tests covering:
    • Docker binary missing → found: false
    • Docker binary + running daemon → found: true, no warning
    • Docker binary + stopped daemon → found: false, warning about daemon
    • Compact compiler missing → found: false
    • Compact compiler version compatibility (pass/fail)
    • Compact compiler newer than expected → passes with warning
    • Port availability on free port → found: true

Why this matters

These are the top two support issues new Windows developers hit:

  • They install Docker Desktop, forget to launch it, then the CLI says "Docker [installed]" and later fails with a cryptic "Cannot connect to the Docker daemon" during setup.
  • They previously ran a proof server, it didn't shut down cleanly, and now docker run fails with "bind: address already in use".

Both failures are now caught before file scaffolding begins, with clear warnings and actionable guidance.

Verification

  • npm run test passes (vitest)
  • New test file src/__tests__/requirement-checker.test.ts covers all new code paths
  • No breaking changes to existing API or user-facing behavior (only adds warnings)
  • No new external dependencies

…-server port

- Extend RequirementChecker.checkDocker() to run `docker info` after detecting the binary. Previously only `docker --version` was checked, which passes even when Docker Desktop is closed and the daemon is down. This led to confusing downstream failures during proof-server setup.

- Add RequirementChecker.checkPortAvailable(port) using a lightweight TCP socket probe to localhost. Warns the user if port 6300 (proof-server default) is already occupied before scaffolding begins, preventing opaque 'port already allocated' errors from Docker.

- Integrate port check into createApp() alongside existing Docker and Compact checks.

- Add comprehensive unit tests (vitest) covering:
  – Docker binary missing
  – Docker installed + daemon running
  – Docker installed + daemon NOT running (warning path)
  – Compact compiler missing
  – Compact compiler version compatibility
  – Compact compiler newer than expected (warning path)
  – Port availability (free port)

Closes silent failures when Docker daemon is off or another process holds port 6300.
@notsoblack
notsoblack requested a review from Olanetsoft as a code owner June 25, 2026 17:34
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Midnight Contributor seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants