Skip to content

fix/docker: pass args directly to binary instead of shell#407

Closed
fuleinist wants to merge 1 commit intoruvnet:mainfrom
fuleinist:fix/docker-args-pass-through
Closed

fix/docker: pass args directly to binary instead of shell#407
fuleinist wants to merge 1 commit intoruvnet:mainfrom
fuleinist:fix/docker-args-pass-through

Conversation

@fuleinist
Copy link
Copy Markdown

Problem

Docker run arguments (e.g. --source wifi) don't reach the sensing-server binary on Windows (and sometimes Linux). Users see:

  • PowerShell: wifi: 1: --source: not found — PowerShell interprets -- as a parameter prefix
  • Linux sh: /bin/sh: 0: Illegal option -- — Docker dispatches --args to /bin/sh -c which chokes on --

Root Cause

The Dockerfile.rust uses shell-form ENTRYPOINT:

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/app/sensing-server --source ${CSI_SOURCE} --tick-ms 100 ..."]

With /bin/sh -c, the entire CMD becomes a shell command string. Any arguments after the container image name are treated as sh options or extra positional args to the shell — they never reach sensing-server.

Fix

Switch to exec-form ENTRYPOINT so arguments pass directly to the binary:

ENTRYPOINT ["/app/sensing-server"]
CMD []

The server already reads CSI_SOURCE from the environment, so -e CSI_SOURCE=simulated continues to work for env-based configuration. Users who prefer CLI args can now write:

docker run ruvnet/wifi-densepose:latest --source simulated

Also update docker-compose.yml command to exec-form JSON array.

Testing

# Before fix (fails on Windows):
#   docker run ruvnet/wifi-densepose:latest --source wifi
#   wifi: 1: --source: not found

# After fix (works on all platforms):
docker run ruvnet/wifi-densepose:latest --source simulated
# → Server starts in simulated mode

docker run -e CSI_SOURCE=simulated ruvnet/wifi-densepose:latest
# → Still works (env var takes precedence in auto mode)

docker compose run sensing-server --source simulated
# → compose also passes args correctly

Fixes #384

Problem: Shell-form ENTRYPOINT ["/bin/sh", "-c"] causes Docker to parse
args as shell options instead of passing them to the server binary. Users
calling 'docker run IMAGE --source wifi' see errors like:
  wifi: 1: --source: not found  (PowerShell parsing)
  /bin/sh: 0: Illegal option --  (Docker shell dispatch)

Fix: Switch to exec-form ENTRYPOINT ["/app/sensing-server"] so that
arguments after the image name reach the binary directly. The server
already reads CSI_SOURCE from the environment, so -e CSI_SOURCE=esp32
still works for environment-based configuration.

Also update docker-compose.yml command to use exec-form JSON array so
compose also passes args correctly.

Fixes ruvnet#384
References: ruvnet#384 (can't start docker container on windows)
@proffesor-for-testing
Copy link
Copy Markdown
Contributor

Thanks @fuleinist for spotting the shell-form ENTRYPOINT problem and writing a clear root-cause explanation — the PowerShell vs /bin/sh -c "--" breakdown is exactly right, and it was useful evidence when reproducing locally. The exec-form swap does unblock docker run image --source wifi, which I verified with a stub-binary Docker image.

@proffesor-for-testing
Copy link
Copy Markdown
Contributor

@ruvnet — recommend closing in favor of #402. Both PRs fix the shell-form ENTRYPOINT (issue #384), and that part of this PR is correct. However, after locally reproducing both against upstream/main:

  1. CSI_SOURCE env var is not actually read by the binary. The PR description says "The server already reads CSI_SOURCE from the environment" — but in sensing-server/src/main.rs:98 the --source arg has no clap env = "…" attribute. So docker run -e CSI_SOURCE=esp32 image is silently ignored under this PR.

  2. Binary defaults mismatch the Dockerfile. With no CLI flags, clap's defaults take over:

    • --http-port8080 vs EXPOSE 3000
    • --ws-port8765 vs EXPOSE 3001
    • --bind-addr127.0.0.1 (won't accept Docker bridge traffic, so -p 3000:3000 doesn't work)
    • --ui-path../../ui (UI not served)

    Result: docker run ruvnet/wifi-densepose:latest still doesn't produce a usable server. docker-compose up works only because compose re-supplies every flag explicitly.

  3. Issue --model / --load-rvf 参数在 Docker 镜像中不生效 #399 (MODELS_DIR / discovered models empty when volume-mounted) is not addressed.

#402 handles all of the above via a dedicated entrypoint script that injects the correct defaults while letting user flags override through clap last-wins.

Thanks again to @fuleinist — the root-cause write-up here is solid and wasn't wasted work; it aligns with the diagnosis in #402.

@ruvnet ruvnet closed this Apr 20, 2026
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.

can't start docker container on windows - wifi: 1: --source: not found

3 participants