docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 287 forks source link

DockerCLI --help "broken" #13435

Open jtnord opened 1 year ago

jtnord commented 1 year ago

Actual behavior

❯ "c:\Program Files\Docker\Docker\DockerCli.exe" -Help
Usage: DockerCli.exe [Command]
  -h, --help, -Help: Show the help information for this command

❯ "c:\Program Files\Docker\Docker\DockerCli.exe" -h
Usage: DockerCli.exe [Command]
  -h, --help, -Help: Show the help information for this command

❯ "c:\Program Files\Docker\Docker\DockerCli.exe" -Help
Usage: DockerCli.exe [Command]
  -h, --help, -Help: Show the help information for this command

❯ "c:\Program Files\Docker\Docker\DockerCli.exe"
Usage: DockerCli.exe [Command]
  -h, --help, -Help: Show the help information for this command

Expected behavior

Help is displayed (e,g the list of commands, and what they do) (even if the tool is somewhat internal - there needs to be a documented way to be able to programatically interact with the docker installation without a UI - even if this can change between release)

The DockerCLI.exe is useful for automation tools that need to perform tasks rather than going via a desktop UI.

e.g. switching between windows containers and linux containers can be accomplished by using the -SwitchDaemon (documented here )

but the other commands are effectively black boxes with no documentation.

I would like to assume that -SwitchLinuxEngine and -SwitchWindowsEngine are the relatives to -SwitchDaemon but switch to the specific platform and do a no-op if that platform is already used.

Information

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

& was unexpected at this time.

Why y'all assume people use powershell 😉

[2023-04-26T18:02:33.114782000Z][com.docker.diagnose.exe][I] set path configuration to OnHost
Starting diagnostics

[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0002: does the bootloader have virtualization enabled?
[SKIP] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[PASS] DD0017: can a VM be started?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0023: is the Containers Windows Feature enabled?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0031: does the Docker API work?
[PASS] DD0013: is the $PATH ok?
[PASS] DD0003: is the Docker CLI working?
[PASS] DD0005: is the user in the docker-users group?
[PASS] DD0038: is the connection to Docker working?
[PASS] DD0014: are the backend processes running?
[PASS] DD0007: is the backend responding?
[PASS] DD0008: is the native API responding?
[PASS] DD0009: is the vpnkit API responding?
[PASS] DD0010: is the Docker API proxy responding?
[PASS] DD0006: is the Docker Desktop Service responding?
[SKIP] DD0030: is the image access management authorized?
[PASS] DD0033: does the host have Internet access?
[PASS] DD0002: does the bootloader have virtualization enabled?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[PASS] DD0017: can a VM be started?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0023: is the Containers Windows Feature enabled?
[PASS] DD0004: is the Docker engine running?
[PASS] DD0015: are the binary symlinks installed?
[PASS] DD0031: does the Docker API work?
[PASS] DD0032: do Docker networks overlap with host IPs?
No fatal errors detected.

Steps to reproduce the behavior

  1. start cmd.exe
  2. run "C:\Program Files\Docker\Docker\DockerCli.exe" -Help
g0t4 commented 1 year ago

Try opening DockerCli.exe with dotPeek, look for a class called Docker.Cli.BackendCli whose Run method lists many of the options:


flags.If("-StartWSL2Engine", (Action) (() => this.RunEngine(EngineType.LinuxWSL2)));
flags.If("-StartWindowsEngine", (Action) (() => this.RunEngine(EngineType.WindowsContainers)));
flags.If("-StartHyperVEngine", (Action) (() => this.RunEngine(EngineType.LinuxHyperV)));
flags.If("-SharedDrives", new Action(this.SharedDrives));
flags.If("-Shutdown", new Action(this.Shutdown));
flags.If("-SwitchDaemon", (Action) (() => this.SwitchDaemon(new ContainerEngineMode?())));
flags.If("-SwitchLinuxEngine", (Action) (() => this.SwitchDaemon(new ContainerEngineMode?(ContainerEngineMode.Linux))));
flags.If("-SwitchWindowsEngine", (Action) (() => this.SwitchDaemon(new ContainerEngineMode?(ContainerEngineMode.Windows))));
flags.If("-h", new Action(BackendCli.Usage));
flags.If("--help", new Action(BackendCli.Usage));
flags.If("-Help", new Action(BackendCli.Usage));
if (!flags.Contains("--testftw!928374kasljf039"))
  return;
flags.If("-Start", new Action(this.Start));
flags.If("-Stop", new Action(this.Stop));
flags.If("-Restart", new Action(this.Restart));
chadmyers commented 7 months ago

In this comment Stefan confirmed that DockerCLI has been removed from current versions of Docker Desktop.

I'm not sure what the replacement is, if any.

g0t4 commented 7 months ago

@chadmyers I just updated to latest DDfW which includes C:\Program Files\Docker\Docker\DockerCli.exe... a brittle tool for sure, but seems still there... the linked comment suggests it may be removed

chadmyers commented 7 months ago

I had DDfW 4.25.0. I just upgraded to 4.27.1 and indeed it is back. Weird! Thank you @g0t4

g0t4 commented 7 months ago

@chadmyers maybe they tried getting rid of it!

I haven't spent much time on it but you might be able to replicate much of what it does by managing services in windows and wsl. DockerCLI.exe is a .net app so it can be decompiled i.e. with dotPeek